这在不到一个月前奏效。有什么改变了吗? (添加简单示例):

adk47sample

PeakName Elevation
Marcy      5344
Marcy      5344
Marcy      5344
Marcy      5344
Marcy      5344
Marcy      5344
Marcy      5344
Algonquin      5114
Algonquin      5114
Algonquin      5114

> require(plyr)
Loading required package: plyr
> adk.need.fr.round.6 <- ddply(adk47sample, .(PeakName, Elevation),
+   summarize, needThese=if(length(PeakName) < 6) "needThis")

Error in class(output[[var]]) <- class(value) :
  attempt to set an attribute on NULL

对于这个简单的例子,我期望:
> adk.need.fr.round.6
      PeakName     Elevation needThese
1     Algonquin      5114     needThis

最佳答案

如果我像@joran 建议的那样给出 plyrelse 结果(使用 character(0) 它给出相同的错误),那么它适用于 else NULL 1.8 版:

adk.need.fr.round.6 <- ddply(adk47sample,
.(PeakName, Elevation),summarize,
  needThese=if(length(PeakName) < 6) "needThis" else character(0))

关于r - plyr::ddply 错误消息:类中的错误(输出 [[var]])<- 类(值):尝试在 NULL 上设置属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14059418/

10-12 17:47