Re: [R] inequality with NA

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Fri 22 Sep 2006 - 18:25:25 GMT

Mag. Ferri Leberl wrote:
> Dear everybody!
> take a<-c(5,3,NA,6).
>
> if(a[1]!=NA){b<-7}
> if(a[3]!=5){b<-7}
> if(a[3]!=NA){b<-7}
> if(a[3]==NA){b<-7}
>
> will alltogeather return
>
> Fehler in if (a[1] != NA) { : Fehlender Wert, wo TRUE/FALSE nötig ist
>
> (or simularly). Somehow this is logical. But how else should I get out,
> whether a certain vector-component has an existing value?

see ?is.na

Hence:

   if(!is.na(a[1])) b <- 7

Uwe Ligges

> Thank you in advance!
> Yours,
> Mag. Ferri Leberl
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.



R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Received on Sat Sep 23 04:28:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Sep 2006 - 19:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.