Closed HenrikBengtsson closed 9 years ago
This is due to a cut'n'paste error from weightedMad()
;
# Are there any values left to calculate the weighted median of?
# This is consistent with how stats::mad() works.
if (n == 0L) {
return(naValue);
} else if (n == 1L) {
zeroValue <- 0;
storage.mode(zeroValue) <- storage.mode(x);
return(zeroValue);
}
It should be:
if (n <= 1L) return(naValue);
weightedVar()
andweightedSd()
on a single element gives zero, but should giveNA_real
, e.g.versus
Ditto on zero elements gives correct results;
Discovered while adding redundancy tests for Issue #72.