[R] odd feature
    Thomas Lumley 
    tlumley at u.washington.edu
       
    Mon May 22 16:09:09 CEST 2006
    
    
  
On Mon, 22 May 2006, Gabor Grothendieck wrote:
> Due to lazy evaluation, I don't think a and b are fully evaluated:
>
>> ifelse(1, a <- 1, b <- 2)
> [1] 1
>> a
> [1] 1
>> b
> Error: object "b" not found
yes. If you look at the code for ifelse() it evaluates the second argument 
if any test values are TRUE and the third argument if any test values are 
FALSE, so in the scalar case it does not evaluate both arguments.
 	-thomas
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle
    
    
More information about the R-help
mailing list