From dciemo@excite.com  Mon May 20 04:42:40 2002
From: dciemo@excite.com (dciemo@excite.com)
Date: Mon, 20 May 2002 05:42:40 +0200 (MET DST)
Subject: [Rd] Use of 'any' in 3.2.1 if ... else example is incorrect  R-lang.pdf (PR#1575)
Message-ID: <200205200342.FAA27132@pubhealth.ku.dk>

Full_Name: David Ciemiewicz
Version: 1.3.1
OS: Windows 2000
Submission from: (NULL) (63.192.218.208)


In the R Language Manual (R-lang.pdf), section 3.2.1 "if", there is an example
expression which uses the function "any".

> if( any(x) <= 0 ) y <- log(1+x) else y <- log(x)
> y <- if( any(x)<= 0 ) log(1+x) else log(x)

However, the parenthesis are incorrect in the conditional part of the if.

It should be:

    if ( any(x <= 0) ) y <- log(1+x) else y <- log(x)
    y <- if ( any(x <= 0) ) log(1+x) else log(x)


However, if we are really being pedantic, this is still not correct.  If any
values of x are <= -1, you will still get an error.

I'm still too new to R to figure out how to get what I thing I really want which
would set all values less than or equal to zero to be 1.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Use of 'any' in 3.2.1 if ... else example is incorrect R-lang.pdf (PR#1575)
dciemo@excite.com