[R] weighted mean by week
dimitri.liakhovitski at gmail.com
Wed Jul 18 03:00:48 CEST 2012
Thanks a lot, David.
Indeed, it's much shorter.
Unfortunately, in my real task I am dozens and dozens of variables
like var1 and var2 so that manually specifying things like in
"m1=weighted.mean(var1,myweight)" would take a lot of code and a very
On Tue, Jul 17, 2012 at 6:34 PM, David Freedman <dxf1 at cdc.gov> wrote:
> The plyr package is very helpful for this:
> ddply(x ,.(myweek), summarize, m1=weighted.mean(var1,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.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help