Re: [R] A suggestion to improve ifelse behaviour with vector yes/noarguments

2005-06-01 Thread Duncan Murdoch
Mäkinen Jussi wrote: Hello, I'm happy with the modified ifelse: ifelse.o - function (test, yes, no) { storage.mode(test) - logical ans - test nas - is.na(test) if (any(test[!nas])) ans[test !nas] - rep(yes, length.out = length(ans))[test !nas] if

RE: [R] A suggestion to improve ifelse behaviour with vector yes/noarguments

2005-06-01 Thread Mäkinen Jussi
Thanks Duncan, For pointing this out. You maybe saved my day. I agree that these results are neither something I would like to see. I changed the code to be: ifelse.o - function (test, yes, no) { storage.mode(test) - logical ans - test nas - is.na(test) if (any(test[!nas]))

Re: [R] A suggestion to improve ifelse behaviour with vector yes/noarguments

2005-05-31 Thread Dimitris Rizopoulos
there is nothing problematic there! According to the help-page of ifelse(), in the Details section you get: If yes or no are too short, their elements are recycled. and this is what you get in your example. Best, Dimitris Dimitris