M�kinen Jussi wrote:
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.
As Dimitris said, this is just recycling. I think getting rid of
recycling on vectors with length greater than 1 would have been a good
decision in S about 15 years ago, but it's too late now.
Duncan Murdoch
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html