0

In R,

how do u retrieve for each node of a tree, the index of observations in each node in the tree, without recoding all the tree iterative procedure?

For example in rpart (an r package):

library(rpart)
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis, cp = -1)
fit$splits 

I would like to know for each splits, which observations go to the right node and which go to the left node.

Malex
  • 41
  • 4
  • Sorry, seems to be already answered here : https://stackoverflow.com/questions/36748531/getting-the-observations-in-a-rparts-node-i-e-cart?rq=1 . If someone wants to provide other links or methods (maybe faster methods for example), please feel free. – Malex Feb 14 '20 at 09:51
  • Does this answer your question? [Getting the observations in a rpart's node (i.e.: CART)](https://stackoverflow.com/questions/36748531/getting-the-observations-in-a-rparts-node-i-e-cart) – shs Feb 14 '20 at 11:39
  • It's working more or less. But a least now i know a way to code it. Thanks. – Malex Feb 14 '20 at 13:44

0 Answers0