On 03/31/2017 10:14 PM, Prof Brian Ripley wrote:
From ?NA
Numerical computations using ‘NA’ will normally result in ‘NA’: a
possible exception is where ‘NaN’ is also involved, in which case
either might result.
and ?NaN
Computations involving ‘NaN’ will return ‘NaN’ or perh
Although help("is.nan") says:
"Computations involving NaN will return NaN or perhaps NA: ..."
it might not be obvious that this is also why one may get:
> mean(c(-Inf, +Inf, NA))
[1] NaN
> mean(c(-Inf, NA, +Inf))
[1] NA
This is because internally the intermediate sum +Inf + -Inf is NaN in
t
On Fri, Mar 31, 2017 at 10:14 PM, Prof Brian Ripley
wrote:
> From ?NA
>
> Numerical computations using ‘NA’ will normally result in ‘NA’: a
> possible exception is where ‘NaN’ is also involved, in which case
> either might result.
>
> and ?NaN
>
> Computations involving ‘NaN’ w
From ?NA
Numerical computations using ‘NA’ will normally result in ‘NA’: a
possible exception is where ‘NaN’ is also involved, in which case
either might result.
and ?NaN
Computations involving ‘NaN’ will return ‘NaN’ or perhaps ‘NA’:
which of those two is not guarantee
In R 3.3.3, I observe the following on Ubuntu 16.04 (when building
from source as well as for the sudo apt r-base build):
> x <- c(NA, NaN)
> mean(x)
[1] NA
> mean(rev(x))
[1] NaN
> rowMeans(matrix(x, nrow = 1, ncol = 2))
[1] NA
> rowMeans(matrix(rev(x), nrow = 1, ncol = 2))
[1] NaN
> .rowMeans(