[R] Bug(?) in predict.tree() --- Evaluation order of Boolean operators
David Smith
dsmith at insightful.com
Fri Feb 15 19:53:44 CET 2002
> || has higher precedence than & in S (-plus, 6.0 and 3.4), but lower
in R.
Actually, in all versions of S-PLUS (as documented in ?Syntax and
following the Blue Book), ||, |, & and && all have the same precedence
and hence are evaluated left to right. This explains Christian's
results.
--
David M Smith <dsmith at insightful.com>
S-PLUS Product Marketing Manager, Insightful Corp, Seattle WA
Tel: +1 (206) 802 2360
Fax: +1 (206) 283 6310
Insightful Corporation provides analytical solutions leveraging
S-PLUS, StatServer, S-PLUS Analytic Server and consulting services.
See www.insightful.com for details.
> -----Original Message-----
> From: christian-za.keller at ubs.com [mailto:christian-za.keller at ubs.com]
> Sent: Friday, February 15, 2002 08:32
> To: p.dalgaard at biostat.ku.dk
> Cc: r-help at stat.math.ethz.ch
> Subject: RE: Re: [R] Bug(?) in predict.tree() --- Evaluation order of
> Boolean operators
>
>
> Dear Peter
>
> Thank you for your help.
>
> >> It's an operator precedence issue. || has higher
> precedence than & in
> >> S (-plus, 6.0 and 3.4), but lower in R.
> >>
> >> Try substitute(T||F&F)[[1]]
> >>
> >> I think we want to be compatible, but we'll not likely change it in
> >> the 1.4.x series. However, a set of parentheses should help...
>
> Note also that in R:
> > T || F & F
> [1] TRUE
> > F & F || T
> [1] TRUE
> > substitute(T || F & F)[[1]]
> ||
> > substitute(F & F || T)[[1]]
> ||
>
> while in S-Plus:
> > T || F & F
> [1] F
> > F & F || T
> [1] T
> > substitute(T || F & F)[[1]]
> &
> > substitute(F & F || T)[[1]]
> ||
>
>
> Christian
>
> ------------------------------------------
> Christian Keller
> ================
> UBS AG
> Analytical CRM UBS CH
> Nüschelerstrasse 22, CH-8098 Zürich
> Tel. +41-1-234 51 48, Fax. +41-1-234 26 83
> christian-za.keller at ubs.com
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _._._._._._._._._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list