I just updated rpart to the latest version (3.1.0). There are a number of changes between this and previous versions, and some of the code I've been using with earlier versions (e.g. 3.0.2) no longer work. Here is a simple illustration of a problem I'm having with xpred.rpart. iris.test.rpart<-rpart(iris$Species~., data=iris[,1:4], parms=list(prior=c(0.5,0.25, 0.25))) + ) > xpred.rpart(iris.test.rpart) Error in as.double.default(fit$parms) : (list) object cannot be coerced to vector type 14 > The problem seems to be with the parms parameter in the call to rpart. If I leave parms out of the fit statement, xpred.rpart works fine. I can't deduce from the help files or the readme what has changed that causes this error (I also can't exactly figure out what the error is). The example use of xpred.rpart works fine, but doesn't have a parms argument in the rpart function call. Any help appreciated. Dr. Marc R. Feldesman email: feldesmanm at pdx.edu email: feldesman at attglobal.net fax: 503-725-3905 "Don't know where I'm going. Don't like where I've been. There may be no exit. But hell, I'm going in." Jimmy Buffett Powered by Superchoerus - the 700 MHz Coppermine Box -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
rpart 3.1.0 bug?
4 messages · Marc R. Feldesman, Brian Ripley
Extra right paren got copied into the first message by mistake. The original did not have the extra and the code below does not work. Also, if you try to use xpred.rpart with "fit2" from the rpart help page, it gives the same error as below (i.e. >xfit <-xpred.rpart(fit2) ) > Error in as.double.default(fit$parms) : (list) object cannot be coerced to vector type 14 >iris.test.rpart<-rpart(iris$Species~., data=iris[,1:4], parms=list(prior=c(0.5,0.25, 0.25))) > xpred.rpart(iris.test.rpart) > Error in as.double.default(fit$parms) : (list) object cannot be coerced to vector type 14
At 01:59 PM 8/12/01, Marc R. Feldesman wrote:
>I just updated rpart to the latest version (3.1.0). There are a number of >changes between this and previous versions, and some of the code I've been >using with earlier versions (e.g. 3.0.2) no longer work. > >Here is a simple illustration of a problem I'm having with xpred.rpart. > >iris.test.rpart<-rpart(iris$Species~., data=iris[,1:4], >parms=list(prior=c(0.5,0.25, 0.25))) >+ ) > > xpred.rpart(iris.test.rpart) >Error in as.double.default(fit$parms) : (list) object cannot be coerced to >vector type 14 > > >The problem seems to be with the parms parameter in the call to rpart. If >I leave parms out of the fit statement, xpred.rpart works fine. > >I can't deduce from the help files or the readme what has changed that >causes this error (I also can't exactly figure out what the error is). The >example use of xpred.rpart works fine, but doesn't have a parms argument in >the rpart function call. > >Any help appreciated. > > >Dr. Marc R. Feldesman >email: feldesmanm at pdx.edu >email: feldesman at attglobal.net >fax: 503-725-3905 > >"Don't know where I'm going. >Don't like where I've been. >There may be no exit. >But hell, I'm going in." Jimmy Buffett > >Powered by Superchoerus - the 700 MHz Coppermine Box > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >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 >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > Dr. Marc R. Feldesman email: feldesmanm at pdx.edu email: feldesman at attglobal.net fax: 503-725-3905 "Don't know where I'm going. Don't like where I've been. There may be no exit. But hell, I'm going in." Jimmy Buffett Powered by Superchoerus - the 700 MHz Coppermine Box -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
There seems to be a simple, if inelegant, fix for the xpred.rpart problem.
In the file xpred.rpart, I found that changing the following line fixed the
bug:
costs <- fit$call$costs
if (is.null(costs))
costs <- rep(1, nvar)
parms<-as.double(fit$parms)
Change last line to:
parms <- as.vector(as.double(unlist(fit$parms)))
This works with all my test examples. I have no idea how this ramifies to
other areas of the code that I don't use. YMMV.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sun, 12 Aug 2001, Marc R. Feldesman wrote:
There seems to be a simple, if inelegant, fix for the xpred.rpart problem.
In the file xpred.rpart, I found that changing the following line fixed the
bug:
costs <- fit$call$costs
if (is.null(costs))
costs <- rep(1, nvar)
parms<-as.double(fit$parms)
Change last line to:
parms <- as.vector(as.double(unlist(fit$parms)))
This works with all my test examples. I have no idea how this ramifies to
other areas of the code that I don't use. YMMV.
None, I expect, and as you pointed out, the test suite does not use it either. It's a change in the original S code from which I am porting. I'll take a look when I have time.
Brian D. Ripley, ripley at 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-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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._