【发布时间】:2016-11-28 19:30:35
【问题描述】:
我有一组列如下
rowid TimePoint2 TimePoint3 TimePoint4 TimePoint5 TimePoint6
我想整理数据,但是当我使用他的粘贴功能时,收集功能无法识别列名 我想要的是
rowid
1 TimePoint2 43
2 TimePoint3 34
3 TimePoint4 24
4 TimePoint5 22
5 TimePoint6 44
等
我的代码:
所以不要写:
y="TimePoint"
Mydf<-
select(df,matches(y),rowid)%>%
gather(variable, value, TimePoint1,TimePoint2,TimePoint3,TimePoint4,TimePoint5,TimePoint6)
我想写这样的东西:
y="TimePoint"
Mydf<-
select(df,matches(y),rowid)%>%
gather(variable, value, paste(y,1:10,",",sep=""))
我得到的错误是Error: All select() inputs must resp;ve to integer column positions. The following do not: * paste (y,1:10,",",sep="")
【问题讨论】:
-
我认为您可以使用 dplyr 中的
starts_with,就像在select()中一样。 -
好的,很好。请添加为答案