Sven Hager
Sven Hager

Reputation: 3194

R Language NaN + NA behaviour

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

Answers (1)

shhhhimhuntingrabbits
shhhhimhuntingrabbits

Reputation: 7475

From ?NaN:

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).

Upvotes: 11

Related Questions