[R] Bug(?) in predict.tree() --- Evaluation order of Boolean operators
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Feb 15 16:54:17 CET 2002
christian-za.keller at ubs.com writes:
> I think the source of the problem is located in the following lines
> of predict.tree():
> if (missing(newdata) || is.null(newdata) & type == "tree")
> return(object)
>
> When missing(newdata) is TRUE the logical expression
> missing(newdata) || is.null(newdata) & type == "tree"
> is always TRUE, whatever is.null(newdata) or type == "tree" are:
> TRUE || FALSE & FALSE
> [1] TRUE
>
> Note that S-Plus 6 for Windows gives
> TRUE || FALSE & FALSE
> [1] F
>
> I don't want to judge which one is correct.
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...
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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