Reputation: 3194
I have a question about arithmetic behaviour in R. Regard the following piece of code
> NaN + NA
[1] NaN
>
>
> NaN + as.integer(NA)
> NA
So, I am confused that these two additions give different results. Does anybody know if this is really wanted behaviour or just some kind of bug?
Thanks in advance
Upvotes: 6
Views: 341
Reputation: 7475
From ?NaN
:
Computations involving
NaN
will returnNaN
or perhapsNA
: which of those two is not guaranteed and may depend on the R platform (since compilers may re-order computations).
Upvotes: 11