[R] question

Liaw, Andy andy_liaw at merck.com
Fri Feb 27 17:02:35 CET 2004


You need know about the difference between & and && (and between | and ||).

Andy

> From: Svetlana Eden
> 
> Hi everybody.
> 
> The question:
> I get two vectors 'iFalseFalse' and 'i2'.
> I think they should be the same but they are not.
> Is it because 
> R does not handle complicated logical expressions in such cases 
> or I do something wrong?
> 
> 
> > z1 = c(NA, "", 3, NA, "", 3)
> > z2 = c("", "", 3, NA, 3, NA)
> > cV = (as.character(z1)==as.character(z2))
> > cV
> [1]    NA  TRUE  TRUE    NA FALSE    NA
> >
> > iFalse = (c(1:(length(z1))))[(cV==FALSE)]
> > iNonNA = (c(1:(length(z1))))[(!(is.na(cV)))]
> > iFalse
> [1] NA NA  5 NA
> >
> > iNonNA
> [1] 2 3 5
> >
> > iFalseFalse = intersect(iFalse, iNonNA)
> > iFalseFalse
> [1] 5
> > i2 = (c(1:(length(z1))))[( (cV==FALSE)&&(!(is.na(cV))) )]
> > i2
> numeric(0)
> >
> 
> -- 
> Svetlana Eden        Biostatistician II            School of Medicine
>                      Department of Biostatistics   Vanderbilt 
> University
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list