On Wed, Feb 3, 2010 at 11:06 AM, David Freedman <3.14david at 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/