john.maindonald@anu.edu.au
2001-Jul-02 22:31 UTC
[Rd] text.rpart: Unwanted NA labels on terminal nodes (PR#1009)
Brian The following (which is new to rw1030) occurs with both Windows 98 & Windows ME. I have not tested behaviour under Unix or Linux, but I expect it is no different. text.rpart() prints unwanted NAs (presumably in the splitting criterion position) on terminal nodes. Criterion <- factor(paste("Leaf", 1:5)) Node <- factor(1:5) assign("tree.df", data.frame(Criterion = Criterion, Node = Node)) nobs <- dim(tree.df)[[1]] u.tree <- rpart(Node ~ Criterion, data = tree.df, all = F, control = list(minsplit = 2, minbucket = 1, cp = 9.999999999999998e-008)) plot(u.tree, uniform=T) text(u.tree) --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = x86 os = Win32 system = x86, Win32 status major = 1 minor = 3.0 year = 2001 month = 06 day = 22 language = R Windows 98 SE 4.10 (build 2222) A Search Path: .GlobalEnv, package:rpart, package:ctest, Autoloads, package:base John Maindonald email : john.maindonald@anu.edu.au Statistical Consulting Unit, phone : (6125)3998 c/o CMA, SMS, fax : (6125)5549 John Dedman Mathematical Sciences Building Australian National University Canberra ACT 0200 Australia -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2001-Jul-03 05:30 UTC
[Rd] text.rpart: Unwanted NA labels on terminal nodes (PR#1009)
On Tue, 3 Jul 2001 john.maindonald@anu.edu.au wrote:> Brian > The following (which is new to rw1030) occurs with both > Windows 98 & Windows ME. I have not tested behaviour > under Unix or Linux, but I expect it is no different.I think you mean this is a change from rpart 2.0-2 to 3.0-0: packages have version numbers too! It's a R/S difference (I would say an R bug) for which the workaround got lost. At the top of text.rpart insert FUN1 <- function(x, y, lab,...){ ind <- lab != "NA" FUN(x[ind], y[ind], lab[ind], ...) } and replace FUN by FUN1 inside if(splits) {} (but not at the end). Fixed in rpart 3.0-1, so update.packages() will give this to you shortly. The difference can be seen in> plot(1:3) > text(2, 3, NA)S's behaviour is much more convenient and logical.> text.rpart() prints unwanted NAs (presumably in the > splitting criterion position) on terminal nodes. > > Criterion <- factor(paste("Leaf", 1:5)) > Node <- factor(1:5) > assign("tree.df", data.frame(Criterion = Criterion, Node = Node)) > nobs <- dim(tree.df)[[1]] > u.tree <- rpart(Node ~ Criterion, data = tree.df, all = F, > control = list(minsplit = 2, minbucket > = 1, cp = 9.999999999999998e-008)) > plot(u.tree, uniform=T) > text(u.tree) > > > --please do not edit the information below-- > > Version: > platform = i386-pc-mingw32 > arch = x86 > os = Win32 > system = x86, Win32 > status > major = 1 > minor = 3.0 > year = 2001 > month = 06 > day = 22 > language = R > > Windows 98 SE 4.10 (build 2222) A > > Search Path: > .GlobalEnv, package:rpart, package:ctest, Autoloads, package:base > John Maindonald email : john.maindonald@anu.edu.au > Statistical Consulting Unit, phone : (6125)3998 > c/o CMA, SMS, fax : (6125)5549 > John Dedman Mathematical Sciences Building > Australian National University > Canberra ACT 0200 > Australia > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._