我不明白如何在R的大df上分组.
第0-12列是唯一的标识符,我想让它们保持原样
我已经try 了很多不同的方法
aggregate(cbind(names(preferences[-c(0, 12)])) ~
cbind(names(preferences[c(0, 12)])), data=preferences, FUN=sum)
我要走了
Error in model.frame.default(formula = cbind(names(preferences[-c(0, 12)])) ~ :
variable lengths differ (found for 'cbind(names(preferences[c(0, 12)]))')
a b c d e
1 f(1) 11 2 15
1 f(1) 12 2 15
2 f(2) 13 4 3
2 f(2) 14 6 4
3 f(3) 15 5 6
a b c d e
1 f(1) 23 4 30
2 f(2) 27 10 7
3 f(3) 15 5 6
Python类似功能df[11:624].groupby(by=col11)
df是48GB,所以速度很重要(python因内存不足而崩溃(250GB))
收到answer分后,我go 看了benchmarks分,这真是太快了!!!!