Categories
BLOG

result funny

Funny result when adding negated logical values together

Now, set up a situation where something evaluates to a logical using the is.na function and the negation operator ! :

Evaluate to TRUE and FALSE :

This is strange. Adding extra brackets seems to fix it, but why is this happening?

1 Answer 1

This is due to operator precedence. See ?Syntax + precedes ! . There are two ways

could be interpreted:

R interprets the expression the first way due to the order of operator precedence. Compare this to

here R interpretes the expression as

Not the answer you’re looking for? Browse other questions tagged r or ask your own question.

Related
Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

  • Blog
  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2020.11.24.38066

Funny result when adding negated logical values together Now, set up a situation where something evaluates to a logical using the is.na function and the negation operator ! : Evaluate to TRUE