[R] if(){} else{}

Hans-Juergen Eickelmann EICKELMA at de.ibm.com
Tue Dec 5 16:33:15 CET 2006


Dear R-community,

my data set looks like 'mat' below.

Plant<-c(NA,1,1,1,NA,NA,NA,NA,NA,1);
Value1<-rnorm(1:10);
Value2<-rnorm(1:10);
mat<-cbind(Plant,Value1,Value2);
I receive data from two different sites.
One site is identified by an interger number, the other site has no data in
column Plant=NA.

My pb:

I'm trying to assign labels "A" or "B" to these 2 sites into a new column,
but my if(){} else{} statement fails with the following statement:
Error in if (is.na(mat$Plant == TRUE)) { :
        argument is of length zero

if(is.na(mat$Plant==TRUE)){mat$Plant1="A"} else{mat$Plant1="B"};

I looked through the avail doc and R-help for some time but wasn't able to
fix the pb.

Thx Hans




More information about the R-help mailing list