[R] A suggestion to improve ifelse behaviour with vector yes/no arguments

From: Mäkinen Jussi <Jussi.Makinen_at_valtiokonttori.fi>
Date: Wed 01 Jun 2005 - 00:15:31 EST


Dear All,

I luckily found the following feature (or problem) when tried to apply ifelse-function to an ordered data.

> test <- c(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)
> ifelse(test, 0, 1:4)

[1] 0 0 0 4 1 2 3
>

It roots into the ifelse-syntax:

ans[!test & !nas] <- rep(no, length.out = length(ans))[!test & !nas]

Would it be possible to disable this feature in the next R-version? For instance change the code to be:

ans[!test & !nas] <- rep(no, length.out = length(ans[!test & !nas]))

which seems to solve the problem.

Best regards,

Jussi Mäkinen

Jussi Mäkinen
Analyst
State Treasury, Finland
www.statetreasury.fi
mailto:jussi.makinen@valtiokonttori.fi



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 Wed Jun 01 00:19:34 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:16 EST