3

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

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
4

1 回答 1

3

如果我给出@joran建议的结果(它给出了相同的错误),它适用于我的plyr版本 1.8 :elsecharacter(0)else NULL

adk.need.fr.round.6 <- ddply(adk47sample, 
.(PeakName, Elevation),summarize, 
  needThese=if(length(PeakName) < 6) "needThis" else character(0))
于 2012-12-27T19:39:08.647 回答