【发布时间】:2018-09-06 00:08:14
【问题描述】:
这应该是一个简单的问题,但我正在苦苦挣扎。
我有一个变量名向量,我想从数据框中排除:
df <- data.frame(matrix(rexp(50), nrow = 10, ncol = 5))
names(df) <- paste0(rep("variable_", 5), 1:5)
excluded_vars <- c("variable_1", "variable_3")
我原以为只用 - 排除 select 语句中的对象就可以了:
select(df, -excluded_vars)
但我收到以下错误:
-excluded_vars 中的错误:一元运算符的参数无效
使用select_()时也是如此
有什么想法吗?
【问题讨论】: