Why does the first line return TRUE, and the third line returns 1? I would expect both lines to return 1. What is the exact meaning of those extra two parentheses in the thi
! has a weird, counter-intuitive precedence in R.
Your first code is equivalent to
!(is.na(5) + !is.na(NA))
That is, ! has lower precedence than +.
!
+