【发布时间】:2014-05-15 13:16:31
【问题描述】:
df <- structure(list(`a a` = 1:3, `a b` = 2:4), .Names = c("a a", "a b"
), row.names = c(NA, -3L), class = "data.frame")
数据看起来像
a a a b
1 1 2
2 2 3
3 3 4
以下调用选择
select(df, 'a a')
给予
Error in abs(ind[ind < 0]) :
non-numeric argument to mathematical function
如何使用select 选择“a a”和/或将其重命名为没有空格的名称?我知道以下方法:
names(df)[1] <- "a"select(df, a=1)select(df, ends_with("a"))
但如果我正在处理大型数据集,我如何在不知道索引号或类似列名的情况下获得精确匹配?
【问题讨论】: