Re: [R] Why can't R understand if(num!=NA)?

2013-05-04 Thread David Winsemius
On May 3, 2013, at 10:58 PM, peter dalgaard wrote: > > On May 3, 2013, at 21:36 , David Winsemius wrote: > >> >> On May 3, 2013, at 10:46 AM, peter dalgaard wrote: >>> >>> >>> Because comparison with an unknown value yields an unknown result. >> >> Anything else would violate the Second La

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread peter dalgaard
On May 3, 2013, at 21:36 , David Winsemius wrote: > > On May 3, 2013, at 10:46 AM, peter dalgaard wrote: >> >> >> Because comparison with an unknown value yields an unknown result. > > Anything else would violate the Second Law of Thermodynamics. We cannot have > comparisons reducing entrop

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread David Winsemius
On May 3, 2013, at 10:46 AM, peter dalgaard wrote: > > On May 3, 2013, at 17:24 , jpm miao wrote: > >> I have a program, when I write >> >> if(num!=NA) >> >> it yields an error message. >> >> However, if I write >> >> if(is.na(num)==FALSE) >> >> it works. >> >> Why doesn't the first state

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread David Winsemius
> > On May 3, 2013, at 17:24 , jpm miao wrote: > >> I have a program, when I write >> >> if(num!=NA) >> > snipped On May 3, 2013, at 10:46 AM, peter dalgaard wrote: > Because comparison with an unknown value yields an unknown result. Anything else would violate the Second Law of Thermody

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread peter dalgaard
On May 3, 2013, at 17:24 , jpm miao wrote: > I have a program, when I write > > if(num!=NA) > > it yields an error message. > > However, if I write > > if(is.na(num)==FALSE) > > it works. > > Why doesn't the first statement work? Because comparison with an unknown value yields an unknown

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread Kevin Wright
At a minimum, the first statement needs "==". Also, is.na() gives TRUE/FALSE. While a logical comparison to NA gives NA as a value. Kevin On Fri, May 3, 2013 at 10:24 AM, jpm miao wrote: > I have a program, when I write > > if(num!=NA) > > it yields an error message. > > However, if I write

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread William Dunlap
ftware wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of jpm miao > Sent: Friday, May 03, 2013 8:25 AM > To: r-help > Subject: [R] Why can't R understand if(num!=NA)? > > I have a progra

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread arun
 num1<- c(0,NA,1,3)  num1==NA #[1] NA NA NA NA  num1!=NA #[1] NA NA NA NA  is.na(num1) #[1] FALSE  TRUE FALSE FALSE A.K. - Original Message - From: jpm miao To: r-help Cc: Sent: Friday, May 3, 2013 11:24 AM Subject: [R] Why can't R understand if(num!=NA)? I have a program

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread Berend Hasselman
On 03-05-2013, at 17:24, jpm miao wrote: > I have a program, when I write > > if(num!=NA) > > it yields an error message. > it? What is unclear about the error message? > However, if I write > > if(is.na(num)==FALSE) > > it works. > > Why doesn't the first statement work? > Read sectio

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread David Winsemius
On May 3, 2013, at 8:24 AM, jpm miao wrote: > I have a program, when I write > > if(num!=NA) > > it yields an error message. > > However, if I write > > if(is.na(num)==FALSE) > > it works. > > Why doesn't the first statement work? Read the "manual": ?"NA" -- David Winsemius Alameda,

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread Marc Schwartz
On May 3, 2013, at 10:24 AM, jpm miao wrote: > I have a program, when I write > > if(num!=NA) > > it yields an error message. > > However, if I write > > if(is.na(num)==FALSE) > > it works. > > Why doesn't the first statement work? > > Thanks, > > Miao NA is undefined: > NA == NA [1]

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread David Carlson
Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jpm miao Sent: Friday, May 3, 2013 10:25 AM To: r-help Subject: [R] Why can't R understand if(num!=N

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread Leandro Marino
You can use only if(!is.na(num)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide com

Re: [R] Why can't R understand if(num!=NA)?

2013-05-03 Thread S Ellison
> -Original Message- > if(num!=NA) > it yields an error message. > Why doesn't the first statement work? 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 va

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

2013-05-03 Thread jpm miao
I have a program, when I write if(num!=NA) it yields an error message. However, if I write if(is.na(num)==FALSE) it works. Why doesn't the first statement work? Thanks, Miao [[alternative HTML version deleted]] __ R-help@r-project.org ma