I wonder about the last sentence in the Details section of the
documentation of 'weighted.mean':
"However, zero weights _are_ handled specially and the corresponding ‘x’
values are omitted from the sum."
The return value of weighted.mean.default is
sum((x * w)[w != 0])/sum(w)
and indeed, it looks as if zero weights are getting special treatment,
but what is wrong with the alternative (equivalent?) expression
sum(x * w) / sum(w)?
Is it a good idea to remove zeros from a vector before applying 'sum' to
it? I don't think so. Anyway, the sentence in the documentation seems to
be uncalled for.
G,
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.