Displaying 1 result from an estimated 1 matches for "r48644".
Did you mean:
748644
2009 Oct 29
1
weighted.mean uses zero when na.rm=TRUE (PR#14032)
The weighted.mean() function replaces NA values with 0.0 when the user
specifies na.rm=TRUE:
x <- c(101, 102, NA)
mean(x, na.rm=TRUE) # 101.5, correct
weighted.mean(x, na.rm=TRUE) # 67.66667, wrong
weighted.mean(x, w=c(1,1,1), na.rm=TRUE) # 67.66667, wrong
weighted.mean(x, w=c(1,1,1)/3, na.rm=TRUE) # 67.66667, wrong
The weights are