Is it possible to solve this issue with
tidyverse (preferable) tools?
library(tidyverse) # I have tibble(a = 1, b = 2, c = 3) #> # A tibble: 1 x 3 #> a b c #> <dbl> <dbl> <dbl> #> 1 1 2 3 # here we apply something like tbl %>% desired_rename_function(last(names(.), 2), c("second", "third")) # I want tibble(a = 1, second = 2, third = 3) #> # A tibble: 1 x 3 #> a second third #> <dbl> <dbl> <dbl> #> 1 1 2 3
Created on 2018-09-11 by the reprex package (v0.2.0).
.vars argument. I believe it could solve the problem if the argument for new names accepted a vector, not a list of functions.
rename() is not flexible as far as I can see, it forces you to specify the exact pairs of column names