Brian, thanks for the prompt reply.
   I am quite new to R and have no clue on how to call internal function.
   Tried the following but failed:
   > .Internal("pred.rpart")
   Error in .Internal("pred.rpart") : invalid .Internal() argument
   > .Internal()
   Error in .Internal() : 0 arguments passed to '.Internal' which requires 1
   > .Primitive("pred.rpart")
   Error in .Primitive("pred.rpart") : no such primitive function
   > .Primitive("rpart-internal")
   Error in .Primitive("rpart-internal") : no such primitive function
   So, I copy the whole source code into my codes
   pred.rpart <- function(fit, x) {

       frame <- fit$frame
       nc <- frame[, c('ncompete', 'nsurrogate')]
   :
   :
   }
   but still have error msg:
   >   where <- pred.rpart(mod, newdata=as.matrix(xLost))
   Error in pred.rpart(mod, newdata = as.matrix(xLost)) :
     unused argument(s) (newdata = c("1335.0", "1335.0", "1335.0", "1335.0",
   .....
   Btw, my predict function is ok.
   >  predictLost <- predict(mod, newdata=data.frame(y=yLost, x=xLost))
   Thanks.
   ----
   Chua Siang Li
   Consultant - Operations Research
   Acceval Pte Ltd
   Tel: 6297 8740
   Email: [EMAIL PROTECTED]
   Website: www.acceval-intl.com
   This  message and any attachments (the "message") are intended for the
   designated recipient only and may contain information that is confidential
   and privileged. If you are not the intended recipient, please notify the
   sender and delete all its contents. Any use , reliance on, reference to,
   review  ,  disclosure or copying of the message and the information it
   contains is prohibited.

   --------- Original Message --------
   From: "Prof Brian Ripley" <[EMAIL PROTECTED]>
   To: "Chua Siang Li" <[EMAIL PROTECTED]>
   Cc: r-help@r-project.org
   Subject: Re: [R] rpart$where and predict.rpart
   Date: 07/22/08 18:51
   On Tue, 22 Jul 2008, Chua Siang Li wrote:
   >
   > Hello there. I have fitted a rpart model.
   > > rpartModel <- rpart(y~., data=data.frame(y=y,x=x),method="class", ....)
   > and can use rpart$where to find out the terminal nodes that each
   > observations belongs.
   > Now, I have a set of new data and used predict.rpart which seems to give
   > only the predicted value with no information similar to rpart$where.
   > May I know how to find out the terminal nodes that each new observations
   > belongs to?
   You need to read the code to answer questions about internals. A very
   quick glance at predict.rpart would have told you that
   where <- pred.rpart(object, rpart.matrix(newdata))
   is what you are looking for. (Note that pred.rpart like many other
   internal functions is not exported from the name space.)
   > Many thanks.
   > ----
   > Chua Siang Li
   > Consultant - Operations Research
   > Acceval Pte Ltd
   > Tel: 6297 8740
   > Email: [EMAIL PROTECTED]
   > Website: [2]www.acceval-intl.com
   --
   Brian D. Ripley, [EMAIL PROTECTED]
   Professor of Applied Statistics, [4]http://www.stats.ox.ac.uk/~ripley/
   University of Oxford, Tel: +44 1865 272861 (self)
   1 South Parks Road, +44 1865 272866 (PA)
   Oxford OX1 3TG, UK Fax: +44 1865 272595

References

   1. mailto:[EMAIL PROTECTED]
   2. http://www.acceval-intl.com/
   3. mailto:[EMAIL PROTECTED]
   4. http://www.stats.ox.ac.uk/~ripley/
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to