[R] weighted mean by week

David Freedman dxf1 at cdc.gov
Wed Jul 18 00:34:45 CEST 2012


The plyr package is very helpful for this:

library(plyr)
ddply(x ,.(myweek), summarize, m1=weighted.mean(var1,myweight),
m2=weighted.mean(var2,myweight))


--
View this message in context: http://r.789695.n4.nabble.com/weighted-mean-by-week-tp4636814p4636816.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list