Description Usage Arguments Examples
View source: R/colwise-select.R
rename_if()
, rename_at()
, and rename_all()
have been superseded by
rename_with()
. The matching select statements have been superseded by the
combination of a select()
+ rename_with()
.
These functions were superseded because mutate_if()
and friends were
superseded by across()
. select_if()
and rename_if()
already use tidy
selection so they can't be replaced by across()
and instead we need a new
function.
1 2 3 4 5 6 7 8 9 10 11 |
.tbl |
A |
.funs |
A function |
... |
Additional arguments for the function calls in
|
.predicate |
A predicate function to be applied to the columns
or a logical vector. The variables for which |
.vars |
A list of columns generated by |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.