Hi expeRts,
I would like to calculate weighted mean by two factors.
My code is as follows:
R tmp - by(re$meta.sales.lkm[, c(pc, sales)],
re$meta.sales.lkm[, c(size, yr)], function(x)
weighted.mean(x[,1], x[,2]))
The result is as follows:
R tmp
size:
Sounds like a job for plyr: http://had.co.nz/plyr
On Mon, Apr 13, 2009 at 7:56 PM, Dong H. Oh r.arec...@gmail.com wrote:
Hi expeRts,
I would like to calculate weighted mean by two factors.
My code is as follows:
R tmp - by(re$meta.sales.lkm[, c(pc, sales)],
Also see the help file for the wtd.mean function in the Hmisc package,
which has an example using the summarize function to do this.
Frank
Mike Lawrence wrote:
Sounds like a job for plyr: http://had.co.nz/plyr
On Mon, Apr 13, 2009 at 7:56 PM, Dong H. Oh r.arec...@gmail.com wrote:
Hi
Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com
---
R] weighted mean and by() with two index
Dong H. Oh r.arecibo at gmail.com
Tue Apr 14 00:56:28 CEST 2009
Hi expeRts,
I would like to calculate weighted mean by two factors.
My code
4 matches
Mail list logo