At 10:42 13/12/2006, Martin Maechler wrote: > >>>>> "[EMAIL PROTECTED]" == [EMAIL PROTECTED] fr <[EMAIL PROTECTED]> > >>>>> on Tue, 12 Dec 2006 22:24:33 +0100 writes: > > [EMAIL PROTECTED]> ...ifelse, a function of three **vector** > [EMAIL PROTECTED]> arguments.... Yes !! I misunderstood the > [EMAIL PROTECTED]> 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 ______________________________________________ R-help@stat.math.ethz.ch 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.