Skip to content
Back to formatted view

Raw Message

Message-ID: <0BDE2460F08BF0429F933A40431A61E801E8244E@vk2kmail01.valtiokonttori.local>
Date: 2005-05-31T14:15:31Z
From: Mäkinen Jussi
Subject: A suggestion to improve ifelse behaviour with vector yes/no arguments

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 at valtiokonttori.fi