[Rd] base::mean not consistent about NA/NaN
murdoch@dunc@n @ending from gm@il@com
Mon Jul 2 18:32:19 CEST 2018
On 02/07/2018 11:25 AM, Jan Gorecki wrote:
> base::mean is not consistent in terms of handling NA/NaN.
> Mean should not depend on order of its arguments while currently it is.
The result of mean() can depend on the order even with regular numbers.
> x <- rep(c(1, 10^(-15)), 1000000)
> mean(sort(x)) - 0.5
> mean(rev(sort(x))) - 0.5
> mean(c(NA, NaN))
> # NA
> mean(c(NaN, NA))
> # NaN
> I created issue so in case of no replies here status of it can be looked up
The help page for ?NaN says,
"Computations involving NaN will return NaN or perhaps NA: which of
those two is not guaranteed and may depend on the R platform (since
compilers may re-order computations)."
And ?NA says,
"Numerical computations using NA will normally result in NA: a possible
exception is where NaN is also involved, in which case either might
result (which may depend on the R platform). "
So I doubt if this inconsistency will be fixed.
> [[alternative HTML version deleted]]
> R-devel using r-project.org mailing list
More information about the R-devel