4
NA | TRUE #output :TRUE 
FALSE & NA #output :FALSE

Can anyone explain how R is interpreting these statements and giving output.

Adam Quek
  • 6,973
  • 1
  • 17
  • 23
RajK
  • 39
  • 2

1 Answers1

5

NA | TRUE returns TRUE because of the | , i.e., the OR-operator which returns true when at least one condition is satisfied.

Likewise, NA | FALSE would return NA because it can not be determined.

On the other hand, with the & AND-operator, the cases are reversed. Also, this is mathematical logic and not specific to the R-language.

Aramis7d
  • 2,444
  • 19
  • 25