【发布时间】:2015-08-12 08:21:03
【问题描述】:
当我尝试根据某些条件重命名变量时,选择函数工作正常
require(dplyr)
select(iris, petal = starts_with("Petal"))
但是,当我尝试使用所有其他变量时
rename(iris, petal = starts_with("Petal"))
Error: Arguments to rename must be unquoted variable names. Arguments petal are not.
我不知道为什么 dplyr 会抱怨这个。如果这种行为是有意的,那么使用starts_with(或包含)重命名变量同时保留其他变量的正确方法是什么?
【问题讨论】: