Re: [Rd] ifelse can't return a list? Please explain (R-2.15.3)

2013-03-25 Thread Patrick Burns
When you what you hope for turns out to be wrong, then have a look at 'The R Inferno'. http://www.burns-stat.com/documents/books/the-r-inferno/ It does talk about 'ifelse'. Pat On 25/03/2013 02:21, Paul Johnson wrote: I hope you are doing well. For me, this was an unexpected problem. I've

[Rd] ifelse can't return a list? Please explain (R-2.15.3)

2013-03-24 Thread Paul Johnson
I hope you are doing well. For me, this was an unexpected problem. I've hoped for quite a few wrong things today, but I'm only asking you about this one. Why does ifelse(1, list(a, b, c), list(x, y, z)) return a list with only a, not list(a, b, c) as I hoped. I wish it would either cause an

Re: [Rd] ifelse can't return a list? Please explain (R-2.15.3)

2013-03-24 Thread Joshua Wiley
Hi Paul, Wonder why this is an R devel thing? ifelse is vectorizedthere should be logical conditions matching the length of the output. ifelse(c(1, 1, 1), list(a=2, b=3, c=4), list(d=1, e=2, f=3)) otherwise it is truncated. Also note that both results have to be valid, because both are