[Rd] New version weighted mean differs from the old one (PR#14142)

From: <huh420_at_dreamwiz.com>
Date: Mon, 14 Dec 2009 21:25:10 +0100 (CET)


Full_Name: Myung-Hoe Huh
Version: 2.10
OS: Windows
Submission from: (NULL) (116.120.84.194)

New Version (2.10.0) weighted mean produces unreasonable result: see below.

     wt <- c(5,  5,  4,  1)/15
     x <- c(3.7,3.3,3.5,2.8)
     x[4] <- NA
     (xm <- weighted.mean(x,wt,na.rm=T))

Outcome is

> (xm <- weighted.mean(x,wt,na.rm=T))
[1] 3.266667

The number is obtained by treating x[4] <- 0

I think the old version(2.8.0)'s weighte mean is more reasonable. The old output was

> (xm <- weighted.mean(x,wt,na.rm=T))
[1] 3.5

The number si obtained ignoring the x[4], which is NA.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 14 Dec 2009 - 21:17:13 GMT

This archive was generated by hypermail 2.2.0 : Mon 14 Dec 2009 - 22:32:35 GMT