One common gotcha is that ifelse() has no way to reconcile attributes between the two alternatives so it takes the attributes for the result from those of the condition, which is almost certainly what you don't want. In particular, this may convert factors to their underlying integer codes.
Another gotcha is that both alternatives are (usually) computed for all indices, whether or not that is sensible. (See, e.g., first example on help page.) -pd > On 10 Jul 2019, at 15:33 , José María Mateos <ch...@rinzewind.org> wrote: > > On Wed, Jul 10, 2019, at 04:39, Eric Berger wrote: >> 1. The ifelse() command is a bit tricky in R. Avoiding it is often a good >> policy. > > You piqued my curiosity, can you elaborate a bit more on this? > > -- > José María (Chema) Mateos || https://rinzewind.org > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.