On Wed, Feb 3, 2010 at 11:06 AM, David Freedman <3.14da...@gmail.com> wrote: > > also, > > library(plyr) > ddply(d,~grp,function(df) weighted.mean(df$x,df$w))
Or ddply(d, "grp", summarise, mean = weighted.mean(x, w)) which is convenient if you want more than one output Hadley -- 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.