[R] [FORGED] Logical Operators' inconsistent Behavior

Hadley Wickham h.wickham at gmail.com
Sun May 21 16:00:42 CEST 2017

On Fri, May 19, 2017 at 6:38 AM, S Ellison <S.Ellison at lgcgroup.com> wrote:
>> 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.
>> As I said *think* about it; don't just go with your immediate knee-jerk
>> (simplistic) reaction.
> Hmm... not sure that was quite fair to the OP. Yes,  FALSE & <anything> == FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see ?'NA'). It is much less obvious that FALSE & <missing> should generate a non-missing value. SQL, for example, generally  takes the view that any expression involving 'missing' is 'missing'.

That's not TRUE ;)

sqlite> select (3 > 2) OR NULL;

sqlite> select (4 < 3) AND NULL;



More information about the R-help mailing list