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

Ernesto Jardim ernesto at ipimar.pt
Tue Mar 18 18:48:48 CET 2003


On Tue, 2003-03-18 at 17:36, Roger Peng wrote:
> 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
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Yes, you're correct. I missunderstood the sentence.

Regards

EJ



More information about the R-help mailing list