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.