It is a simple question, but why is NA^0 = 1
in R? I didn't realize this until getting surprising results. Shouldn't this result in NA? All the other numeric operations applied to NA seem to return NA as expected.
Asked
Active
Viewed 76 times
2

Rorschach
- 31,301
- 5
- 78
- 129
-
See: http://stackoverflow.com/questions/17863619/why-does-nan0-1 – Sam Firke Apr 18 '15 at 01:36
-
Looks like the check for bases of 1 or exponents of 0 happen before the check for NA: https://github.com/wch/r-source/blob/6d99f42982c486c12f54b937484ad41b8d608bb4/src/main/arithmetic.c#L200 – MrFlick Apr 18 '15 at 01:38
-
@MrFlick thanks, should I delete this or leave it as a link to the NaN question? I didn't think to search NaN. – Rorschach Apr 18 '15 at 01:41
-
It is a slightly different question even if the answer is exactly the same. Might as well leave it up. – MrFlick Apr 18 '15 at 01:42
-
1It's also why `1^NA == 1` – MrFlick Apr 18 '15 at 01:43