The select function works fine when I try to rename variables according to certain conditions
require(dplyr) select(iris, petal = starts_with("Petal"))
However, when I try to save all other variables using
rename(iris, petal = starts_with("Petal")) Error: Arguments to rename must be unquoted variable names. Arguments petal are not.
I have no idea why dplyr complains about this. If this behavior is intended, what is the correct way to rename variables using start_with (or contains) while storing other variables there?
r dplyr
Yifei
source share