[R] density with weights missing values
murdoch@dunc@n @end|ng |rom gm@||@com
Mon Jul 12 23:03:08 CEST 2021
On 12/07/2021 1:22 p.m., matthias-gondan wrote:
> You're right, of course. Extrapolating your argument a bit, the whole practice of na.rm is questionable, since there's always a reason for missingness (that is not in x and rarely elsewhere in the data)Best wishes Matthias
For what it's worth, I partly agree with you: if you specify na.rm =
TRUE, it shouldn't make your x and weights vectors incompatible.
Regarding the warning about the sum of weights: perhaps there's some
reason that someone would want to create an unnormalized density, and
that lets you do it. An unnormalized mean doesn't make any sense, so I
wouldn't call it a design flaw that the weighted density behaves
differently than the weighted mean. On the other hand, it would likely
make more sense to normalize the density, and that's how I hope I would
have designed it.
Thinking about this, I guessed density() was a really old function, so
this was a case of trying to be S-compatible, but it turns out the
weights argument was added in 2005 in r34130, so perhaps someone still
remembers what the thinking was.
P.S. I think you're posting in HTML, which makes your messages look
really messy. If you can turn that off, they'd be clearer.
More information about the R-help