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
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]))
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