EVOLUTION-MANAGER
Edit File: faq-selection-context.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: FAQ - Error: Must be used within a _selecting_ function</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for faq-selection-context {tidyselect}"><tr><td>faq-selection-context {tidyselect}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>FAQ - Error: Must be used within a <em>selecting</em> function</h2> <h3>Description</h3> <p>Functions like <code>starts_with()</code>, <code>contains()</code> or <code>matches()</code> are <strong>selection helpers</strong> that only work in a selection context. </p> <p>Examples of valid selection contexts are: </p> <ul> <li><p> Inside <code>dplyr::select()</code>. </p> </li> <li><p> The <code>cols</code> argument of <code>tidyr::pivot_longer()</code>. </p> </li></ul> <p>Using a selection helper anywhere else results in an error:<div class="r"></p> <pre>starts_with("foo") #> Error: `starts_with()` must be used within a *selecting* function. #> i See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>. mtcars[contains("foo")] #> Error: `contains()` must be used within a *selecting* function. #> i See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>. subset(mtcars, select = matches("foo")) #> Error: `matches()` must be used within a *selecting* function. #> i See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>. </pre></div> <p>If you see this error, you’ve probably used a selection helper in the wrong place, possibly as the result of a typo (e.g. misplaced comma or wrong argument name). </p> <hr /><div style="text-align: center;">[Package <em>tidyselect</em> version 1.1.0 <a href="00Index.html">Index</a>]</div> </body></html>