[R] odd feature

From: ivo welch <ivowel_at_gmail.com>
Date: Sun 21 May 2006 - 23:27:00 EST

Dear R wizards:

I just got stung by the ifelse() feature.

> a <- 10:15
> b <- 20:300
> test <- 1
> ifelse(test,a,b)

[1] 10

I had not realized that this was the default behavior---I had expected 10:15. mea culpa. however, I wonder whether it would make sense to replace ifelse with a different semantic, where if test is a single scalar, it means what a stupid user like me would imagine.

Aside, I like the flexibility of R, but I am not thrilled by all the recycling rules. I either mean I want a scalar or a vector of equal/appropriate dimension. I never want a recycle of a smaller vector. (I do often use a recycle of a scalar.)



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun May 21 23:31:23 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.