我正在使用plyr包在数据框InsectSprays(以R为基础)中练习R:
ddply(InsectSprays,.(spray), summarize, sum = sum(count))
Error in .fun(piece, ...) : argument "by" is missing, with no default
我不明白此错误的含义,本教程执行的命令完全相同,并且输出如下:
spray sum
1 A 174
2 B 184
3 C 25
我也想创建一个新变量(仍然错误):
spraysum <- ddply(InsectSprays,.(spray), summarize, sum = ave(count,FUN = sum))
Error in .fun(piece, ...) : argument "by" is missing, with no default
答案 0 :(得分:0)
#cargar la librerias
library(plyr,dplyr)
ddply(InsectSprays,.(spray), summarize ,sum=sum(count))
结果:
spray sum
1 A 174
2 B 184
3 C 25
4 D 59
5 E 42
6 F 200