【发布时间】:2014-06-16 19:34:52
【问题描述】:
我有一个数据框,DF,列名都包含颜色名:
red_balloons green_balloons red_balls blue_balls green_hats red_horses yellow_things
我想做的是根据多个颜色名称选择多个列。我可以像这样一次选择一列:
grep("red", colnames(DF))
但我无法弄清楚或找出如何选择多个列。我试过这个:
grep(c("red", "blue"), colnames(DF))
但收到以下警告:
Warning message:
In grep(c("mean()", "std()"), colnames(L21), value = FALSE) :
argument 'pattern' has length > 1 and only the first element will be used
建议?
【问题讨论】: