[R] rpart.object help

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Dec 13 10:03:26 CET 2010


On Sun, 12 Dec 2010, jagdeesh_mn wrote:

> Hi,
>
> Suppose i have generated an object using the following :
> fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
>
> And when i print fit, i get the following :
>
> n= 81
>
> node), split, n, loss, yval, (yprob)
>      * denotes terminal node
>
> 1) root 81 17 absent (0.7901235 0.2098765)
>   2) Start>=8.5 62  6 absent (0.9032258 0.0967742)
>     4) Start>=14.5 29  0 absent (1.0000000 0.0000000) *
>     5) Start< 14.5 33  6 absent (0.8181818 0.1818182)
>      10) Age< 55 12  0 absent (1.0000000 0.0000000) *
>      11) Age>=55 21  6 absent (0.7142857 0.2857143)
>        22) Age>=111 14  2 absent (0.8571429 0.1428571) *
>        23) Age< 111 7  3 present (0.4285714 0.5714286) *
>   3) Start< 8.5 19  8 present (0.4210526 0.5789474) *
>
> Is it possible to extract the splits alone as a matrix using rpart.object?
> If so, how?

What do you think 'rpart.object' is?  There is no such function in R.
If you read help("rpart.object") it describes the returned object. 
You are probably looking for fit$frame, but if you want something 
else, study

rpart:::print.rpart

to see how that output is computed.

> Regards,
> Jagdeesh

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list