R NaN + NA language behavior

I have a question about arithmetic behavior in R. Note the following code snippet

> NaN + NA [1] NaN > > > NaN + as.integer(NA) > NA 

So, I am confused that these two additions give different results. Does anyone know if this behavior is really or just some kind of mistake?

Thank you in advance

+4
source share
1 answer

From ?NaN :

Calculations involving NaN will return NaN or possibly NA : which of the two is not guaranteed and may depend on the R platform (since compilers can reorder the calculations).

+9
source

All Articles