[R] argh .. if/else .. why?

hadley wickham h.wickham at gmail.com
Mon Feb 15 17:01:52 CET 2010


> I, personally, utilize the ifelse(test,statement,statement) function when possible over the methodology outlined.

if + else and ifelse perform quite different tasks, and in general can
not (and should not) be exchanged.  In particular, note that for
ifelse, "the class attribute of the result is taken from ‘test’ and
may be inappropriate for the values selected from ‘yes’ and  'no’".

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list