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

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

>>>>> "iw" == ivo welch <> writes:

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

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

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

______________________________________________ mailing list
PLEASE do read the posting guide!
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