Skip to content
Prev 322926 / 398502 Next

Why can't R understand if(num!=NA)?

Because you just compared something with NA (usually interpreted as 'missing')  and because of that the comparison result is also NA. 
'if' then tells you that you have a missing value where you need either TRUE or FALSE.
Play with
num!=NA #returns NA
and
if(NA) "Not there"  #returns error

is.na() returns TRUE for NA's, so 'if' knows what to do with the answer.

S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}