On 19/05/17 21:48, Ramnik Bansal wrote:

Hi,

I need to understand the inconsistent behaviour of & and I operators when
used with NA.

The code below explains this inconsistency

TRUE & NA
[1] NA

FALSE & NA
[1] FALSE

TRUE & NA
[1] NA

FALSE | NA
[1] NA

TRUE | NA
[1] TRUE

TRUE == NA
[1] NA

FALSE == NA
[1] NA

What inconsistency?  It all makes complete sense.  Think about it.

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.

Und so weiter.

As I said *think* about it; don't just go with your immediate knee-jerk (simplistic) reaction.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to