[R] ifelse misusage become more and more frequent...
Michael Dewey
info at aghmed.fsnet.co.uk
Wed Dec 13 14:37:12 CET 2006
At 10:42 13/12/2006, Martin Maechler wrote:
> >>>>> "jropers at freesurf" == jropers at freesurf fr <jropers at freesurf.Fr>
> >>>>> on Tue, 12 Dec 2006 22:24:33 +0100 writes:
>
> jropers at freesurf> ...ifelse, a function of three **vector**
> jropers at freesurf> arguments.... Yes !! I misunderstood the
> jropers at freesurf> functioning of ifelse.
>
>Seems to happen more an more often.
>When I teach "R programming" I nowadays usually emphasize that people
>should often *NOT* use ifelse().
>In other words, I think ifelse() is much over-used in situations
>where something else would be both clearer and more efficient.
>
>Is there a document / book around which lures people into
>misusing ifelse() so frequently?
Perhaps it is because here two concepts are involved which may be
less familiar to people: program control and vectorisation. I wonder
whether the manual pages for ifelse and if need to do more than just
See also the other one. I notice that the page for if has a very
helpful health warning about putting braces round everything. This is
unusual in the manual pages which usually describe what is rather
than tell you explicitly what to do to achieve salvation. Perhaps I
could suggest that the if page tells you what error message you get
when you wanted ifelse and that the ifelse page has a health warning
along the lines of 'ifelse is not if and they are often confused with
difficult to understand results'.
[snip]
Michael Dewey
http://www.aghmed.fsnet.co.uk
More information about the R-help
mailing list