[R] party - ctree() - terminal nodes reference for every obs

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Mon Jul 17 15:39:01 CEST 2006


On Fri, 14 Jul 2006, Daniele Medri wrote:

> Dear R.Users,
>
> using ctree() (from "party" library) on a data.frame, I want to append a
> column with the references for the groups/segments detected. While these
> nodes are easy readable in output, I need a vector for my obs.
>

Daniele,

do you mean a factor coding the terminal node numbers for each 
observation? This is the `where' slot in objects returned from `ctree', 
for example :

>  airq <- subset(airquality, !is.na(Ozone))
>          airct <- ctree(Ozone ~ ., data = airq,
+                         controls = ctree_control(maxsurrogate = 3))
> factor(airct at where)
   [1] 5 5 5 5 5 5 5 5 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 3 5 6 9 9 6 5 5 5 5 
5 8 9
  [38] 6 8 9 8 8 8 8 5 6 6 3 6 8 8 9 3 8 8 6 9 8 8 8 6 3 6 6 8 8 8 8 9 8 9 
6 6 5
  [75] 3 5 6 6 5 5 6 3 8 9 8 8 8 8 8 8 8 8 9 6 6 5 5 6 5 3 5 5 3 5 5 5 6 5 
5 6 5
[112] 5 3 5 5 5
Levels: 3 5 6 8 9

Hope that helps,

Torsten


> Hints?
>
>
> Cheers
> -- 
> Daniele Medri
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.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