[R] weighted.mean and na.rm=T in R-1.6.2

Roger Peng rpeng at stat.ucla.edu
Tue Mar 18 18:36:57 CET 2003


It seems you have NA's in the weights.  But from ?weighted.mean:

Details:

     If `w' is missing then all elements of `x' are given the same
     weight.

     Missing values in `w' are not handled.

Here, `w' is the vector of weights.

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On 18 Mar 2003, Ernesto Jardim wrote:

> Hi
> 
> It looks like the na.rm flag is not working in function weighted.mean.
> 
> > weighted.mean(mat95$U,mat95$fpanual)
> [1] NA
> > weighted.mean(mat95$U,mat95$fpanual,na.rm=TRUE)
> [1] NA
> > mat95 <- mat95[!is.na(mat95$fpanual),]
> > weighted.mean(mat95$U,mat95$fpanual)
> [1] 14.93259
> 
> 
> Regards
> 
> EJ
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>



More information about the R-help mailing list