2009/10/6 Uwe Ligges <[email protected]>:
>
> The first rule is easy: As long as you are using scalar valued (i.e. length
> 1 vectors in R) "cond", you should prefer
> if(cond) cons.expr else alt.expr
> rather than
> ifelse(cond, yes, no)
> because the latter one evaluates both "yes" and "no" while the former one
> evaluates exactly one of both expressions.
I don't think that that is true. The false leg was not evaluated here:
> ifelse(TRUE, { cat("a"); 1}, {cat("b"); 2})
a[1] 1
______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.