【发布时间】:2010-12-04 22:16:57
【问题描述】:
我有一个汇总表:
> aggdata[1:4,]
Group.1 Group.2 x
1 4 0.05 0.9214660
2 6 0.05 0.9315789
3 8 0.05 0.9526316
4 10 0.05 0.9684211
当我有 Group.1 和 Group.2 的值时,如何选择 x 值?
我试过了:
aggdata[aggdata[,"Group.1"]==l && aggdata[,"Group.2"]==lamda,"x"]
但这会回复所有的 x。
更多信息: 我想这样使用:
table = data.frame();
for(l in unique(aggdata[,"Group.1"])) {
for(lambda in unique(aggdata[,"Group.2"])) {
table[l,lambda] = aggdata[aggdata[,"Group.1"]==l & aggdata[,"Group.2"]==lambda,"x"]
}
}
任何更容易并给出这个结果的建议我都很感激!
【问题讨论】:
标签: r