Is there a way "dplyr way" to rename a subset of variables from a data.frame based on variables name translator (vt), a data.frame containing columns with the old and new variable names (old_varname and new_varname respectively). For example:
d <- iris
vt <- data.frame(old_varname=c('Sepal.Length','Petal.Length'),
new_varname=c('a','b'))
d <- d %>% rename_( .... )
#In base R code, this would be:
names(d)[names(d) %in% vt$old_varname] <- vt$std_varname
Edit: Further clarification:
- Assume the vector of variables to be translated is very long, so writing the old-new name pairs by hand is not viable
- The variables to be renamed are a subset of total variables, I still want to keep all variables