Hello!

I have data frame with 'weights' in one of the columns. I need to compute weighted mean on another column other factor variable and i am trying to:

res<-tapply(data$k,list(data$model),weighted.mean,w=data$w,na.rm=T)

and i get:

Warning messages:
1: longer object length
        is not a multiple of shorter object length in: x * w
2: longer object length
        is not a multiple of shorter object length in: x * w
3: longer object length
        is not a multiple of shorter object length in: x * w
4: longer object length
        is not a multiple of shorter object length in: x * w
5: longer object length
        is not a multiple of shorter object length in: x * w
6: longer object length
        is not a multiple of shorter object length in: x * w
7: longer object length
        is not a multiple of shorter object length in: x * w
8: longer object length
....

What i am doing wrong? How i can pass vector of weights to the 'weighted.mean' when using 'tapply'?

Thanks!

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to