plyr :: ddply错误消息:类中的错误(输出[[var]])< - 类(值):尝试在NULL上设置属性

时间:2012-12-27 18:28:38

标签: r plyr

这项工作不到一个月前。有什么变化? (添加简单样本):

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

1 个答案:

答案 0 :(得分:3)

如果{@ 1}} plyr结果为else而@joran建议(character(0)出现同样的错误),那么else NULL版本为1.8适用于我:< / p>

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