Re: [R] srt --- slope text with function?

From: Patricia J. Hawkins <phawkins_at_connact.com>
Date: Sun 12 Feb 2006 - 07:30:41 EST

>>>>> "iw" == ivo welch <ivowel@gmail.com> writes:

iw> * SUGGESTION: can we please offer the "?:" operator ala C in iw> addition to ifelse()? This would make R code prettier.

R:
if (condition) xxx else yyy
if (condition) xxx else if (yyy) zzz else qqq

C:
condition ? xxx : yyy;
condition ? xxx : yyy ? zzz : qqq;

If this is a beauty contest, or a readability contest, I'll take R!

?: is pleasant in C because it avoids so much of the C syntactic sugar, of which R is largely free.

As for ifelse(), for a trivial example, try running: ifelse(array(rep(c(1,0), 50), dim=c(10,10)), "00", "99")

iw> Similarly, perl has a nice construct, which would be lovely, but
iw> which may not jive with the
iw> R syntax:
iw>     condition  or die("the condition", condition, "has failed");
iw>     condition  and cat("my condition", condition, "is met");

        if (!condition) stop("the condition", condition, "has failed")
        if (condition)  cat("my condition", condition, "is met")

-- 
Patricia J. Hawkins
Hawkins Internet Applications
www.hawkinsia.com

______________________________________________
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
Received on Sun Feb 12 07:44:21 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:27 EST