Hi,

I noticed whether some one could explain why "&" and "&&" behave differently in 
data frame transformations.

Consider the following :

a<-data.frame(r=c(0,0,2,3),g=c(0,2,0,2.1))

Then:

> transform(a,R=ifelse(r>0 && g> 0,log(r/g),NA))

  r   g  R
1 0 0.0 NA
2 0 2.0 NA
3 2 0.0 NA
4 3 2.1 NA

but 

> transform(a,R=ifelse(r>0 & g> 0,log(r/g),NA))
  r   g         R
1 0 0.0        NA
2 0 2.0        NA
3 2 0.0        NA
4 3 2.1 0.3566749


If my understanding of the differences between "&" and "&&" and how 'transform' 
works are accurate, both statements should produce the same output.


I got the same behaviour in Windows XP Pro 32-bit (running R v 2.7) and Ubuntu 
Hardy (running the same version of R).


Thanks

Christos Argyropoulos

University of Pittsburgh Medical Center
_________________________________________________________________
Discover the new Windows Vista

E
______________________________________________
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 commented, minimal, self-contained, reproducible code.

Reply via email to