EVOLUTION-MANAGER
Edit File: select_all.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: Select and rename a selection of variables</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 select_all {dplyr}"><tr><td>select_all {dplyr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Select and rename a selection of variables</h2> <h3>Description</h3> <a href='https://www.tidyverse.org/lifecycle/#superseded'><img src='figures/lifecycle-superseded.svg' alt='Superseded lifecycle'></a> <p><code>rename_if()</code>, <code>rename_at()</code>, and <code>rename_all()</code> have been superseded by <code>rename_with()</code>. The matching select statements have been superseded by the combination of a <code>select()</code> + <code>rename_with()</code>. </p> <p>These functions were superseded because <code>mutate_if()</code> and friends were superseded by <code>across()</code>. <code>select_if()</code> and <code>rename_if()</code> already use tidy selection so they can't be replaced by <code>across()</code> and instead we need a new function. </p> <h3>Usage</h3> <pre> select_all(.tbl, .funs = list(), ...) rename_all(.tbl, .funs = list(), ...) select_if(.tbl, .predicate, .funs = list(), ...) rename_if(.tbl, .predicate, .funs = list(), ...) select_at(.tbl, .vars, .funs = list(), ...) rename_at(.tbl, .vars, .funs = list(), ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.tbl</code></td> <td> <p>A <code>tbl</code> object.</p> </td></tr> <tr valign="top"><td><code>.funs</code></td> <td> <p>A function <code>fun</code>, a purrr style lambda <code>~ fun(.)</code> or a list of either form.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments for the function calls in <code>.funs</code>. These are evaluated only once, with <a href="../../rlang/html/dyn-dots.html">tidy dots</a> support.</p> </td></tr> <tr valign="top"><td><code>.predicate</code></td> <td> <p>A predicate function to be applied to the columns or a logical vector. The variables for which <code>.predicate</code> is or returns <code>TRUE</code> are selected. This argument is passed to <code><a href="../../rlang/html/as_function.html">rlang::as_function()</a></code> and thus supports quosure-style lambda functions and strings representing function names.</p> </td></tr> <tr valign="top"><td><code>.vars</code></td> <td> <p>A list of columns generated by <code><a href="vars.html">vars()</a></code>, a character vector of column names, a numeric vector of column positions, or <code>NULL</code>.</p> </td></tr> </table> <h3>Examples</h3> <pre> mtcars <- as_tibble(mtcars) # for nicer printing mtcars %>% rename_all(toupper) # -> mtcars %>% rename_with(toupper) # NB: the transformation comes first in rename_with is_whole <- function(x) all(floor(x) == x) mtcars %>% rename_if(is_whole, toupper) # -> mtcars %>% rename_with(toupper, where(is_whole)) mtcars %>% rename_at(vars(mpg:hp), toupper) # -> mtcars %>% rename_with(toupper, mpg:hp) # You now must select() and then rename mtcars %>% select_all(toupper) # -> mtcars %>% rename_with(toupper) # Selection drops unselected variables: mtcars %>% select_if(is_whole, toupper) # -> mtcars %>% select(where(is_whole)) %>% rename_with(toupper) mtcars %>% select_at(vars(-contains("ar"), starts_with("c")), toupper) # -> mtcars %>% select(!contains("ar") | starts_with("c")) %>% rename_with(toupper) </pre> <hr /><div style="text-align: center;">[Package <em>dplyr</em> version 1.0.2 <a href="00Index.html">Index</a>]</div> </body></html>