Skip to content

Should vars_rename() accept index numbers? #20

@yutannihilation

Description

@yutannihilation

I feel this behavior a bit inconsistent, as select() and rename() shares the same semantics to some extent.

vars_select(names(mtcars), new = 1)
#>   new 
#> "mpg" 
vars_rename(names(mtcars), new = 1)
#> Error: `new` = 1 must be a symbol or a string, not a double vector

For example, they both accept characters. Are there any reason to prevent rename from accepting numbers? (This is not a big problem for me, though. This issue is mostly for my curiosity).

vars_rename(names(mtcars), new = "cyl")
#>    mpg    new   disp     hp   drat     wt   qsec     vs     am   gear   carb 
#>  "mpg"  "cyl" "disp"   "hp" "drat"   "wt" "qsec"   "vs"   "am" "gear" "carb" 
vars_select(names(mtcars), new = "cyl")
#>   new 
#>  "cyl"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions