Re: [R] odd feature

From: Thomas Lumley <>
Date: Tue 23 May 2006 - 00:09:09 EST

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 Lumley			Assoc. Professor, Biostatistics	University of Washington, Seattle

______________________________________________ mailing list PLEASE do read the posting guide! Received on Tue May 23 00:13:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 23 May 2006 - 02:10:14 EST.

Mailing list information is available at Please read the posting guide before posting to the list.