[R] How to collect trees grown by rpart

Sean Davis sdavis2 at mail.nih.gov
Fri Mar 19 19:03:08 CET 2004


Jonathan,

Try making a list instead of an array.  See ?list.  Also, did you look into
random forests?  I'm not sure what you want to do, but there might be
methods there to do some of the work for you.

Sean

On 3/19/04 1:12 PM, "Jonathan Williams"
<jonathan.williams at pharmacology.oxford.ac.uk> wrote:

> I would like to collect the trees grown by rpart fits in an array,
> in order to be able to use them later to predict new data. I have
> tried to use parse and eval to do this, without success. I'd be
> very grateful if someone could explain how to do it.
> 
> The kind of thing I hope to do is:
> 
> resmat=array(NA, 100)
> for (run in 1:100) resmat[run]=rpart(y~., data=train[run])
> 
> So that, later, I can do:
> for (run in 1:100) pred[run]=predict(resmat[run], newdat)
> 
> But, resmat[run] does not work, even though it saves the cptables.
> 
> Thanks, in advance,
> 
> Jonathan Williams
> OPTIMA
> Radcliffe Infirmary
> Woodstock Road
> OXFORD OX2 6HE
> Tel +1865 (2)24356
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list