> daply(data.test, .(municipality, employed), function(d){mean(d$age)} ) > employed > municipality no yes > A 41.58759 44.67463 > B 55.57407 43.82545 > C 43.59330 NA > > The .drop argument has a different meaning in daply. Some R functions have > an na.last argument, and it may be that somewhere in daply, there is a > function call that moves all NAs to the end. The means are in the right > order except for the first, where the NA is supposed to be, so everything is > offset in the table by 1. I've cc'ed Hadley on this.
This is a bug, which I've fixed in the development version (hopefully to be released next week). In the plyr 1.2: > daply(data.test, .(municipality, employed), function(d){mean(d$age)} ) employed municipality no yes A NA 39.49980 B 44.69291 51.63733 C 57.38072 45.28978 Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.