[R] Inconsistency of 1^NA=1 vs. 1.1^NA=NA
Duncan Murdoch
murdoch.duncan at gmail.com
Thu Nov 17 21:13:00 CET 2016
On 17/11/2016 2:19 PM, Da Zheng wrote:
> Hello,
>
> I just realized that 1^NA outputs 1 while 1.1^NA outputs NA in R v3.3.1 and
> R v3.2.3.
> I tried other values such as 0^NA and 2^NA, and they all output NA.
> I don't understand this inconsistency here. Shouldn't 1^NA output NA as
> well? Why does R handle it differently? Or is this a bug in these
> particular versions of R?
Our usual interpretation of NA is "an unknown value". So 1^NA would
give NA if there were multiple possible values for it depending on what
number you substitute for NA, and should give the unique answer if
there's only one possibility (as for example NA | TRUE gives TRUE).
As far as I can see, 1 raised to any power (even infinite ones) should
give 1, so the answer looks fine to me. That's not true of any of the
other bases you mention (just as NA | FALSE gives NA).
Duncan Murdoch
More information about the R-help
mailing list