Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treatment by rename_at() of function with no argument not covered in documentation #5545

Closed
david-romano opened this issue Oct 2, 2020 · 1 comment

Comments

@david-romano
Copy link

In the documentation for select_all() (and related commands), the .funs argument is described as follows:

.funs | A function fun, a purrr style lambda ~ fun(.) or a list of either form.

If the value passed to .funs is a 0-ary function that returns a character vector of the right length, this vector is used to rename columns according to (relative) column index:

library(tidyverse)
mpg %>% 
  rename_at(2:3, ~ letters[1:2])
#> # A tibble: 234 x 11
#>    manufacturer a            b  year   cyl trans   drv     cty   hwy fl    class
#>    <chr>        <chr>    <dbl> <int> <int> <chr>   <chr> <int> <int> <chr> <chr>
#>  1 audi         a4         1.8  1999     4 auto(l… f        18    29 p     comp…

In other words, in this case the value passed to .funs is not treated as a function, which instead would assign the entire character vector as the name of every column. A mention of this special case in the documentation would be helpful.

@hadley
Copy link
Member

hadley commented Nov 16, 2020

rename_at() is superseded, so unfortunately this means that we won't improve the docs.

@hadley hadley closed this as completed Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants