.fun(piece,...)中的错误:缺少参数“ by”,没有默认值-plyr软件包

时间:2018-11-26 21:59:00

标签: r plyr

我正在使用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

1 个答案:

答案 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