Re: [R] density with weights missing values

2021-07-13 Thread Göran Broström
Den 2021-07-12 kl. 15:09, skrev Matthias Gondan: Weighted mean behaves differently: One difference is that density has a named argument 'weights' not present in weighted.mean, which instead has 'w' for weights. Annoying. So, in your examples, the argument 'weights = ' is always ignored, a

Re: [R] density with weights missing values

2021-07-13 Thread Matthias Gondan
Thanks Martin and the others. I will do so accordingly. I guess the 0.1% of the population who uses density with weights will write code like this x = c(1, 2, 3, NA) weights = c(1, 1, 1, 1) density(x[!is.na(x)], weights=weights[!is.na(x)]) These people won’t be affected. For the 0.01% of peopl

Re: [R] density with weights missing values

2021-07-13 Thread Martin Maechler
> Matthias Gondan > on Mon, 12 Jul 2021 15:09:38 +0200 writes: > Weighted mean behaves differently: > • weight is excluded for missing x > • no warning for sum(weights) != 1 >> weighted.mean(c(1, 2, 3, 4), weights=c(1, 1, 1, 1)) > [1] 2.5 >> weighted.mean(c(1,