How to retrieve the clustering results of rpart I am using rpart package in order to create a segmentation of my data using decision tree. As final result I want to obtain a classification of my data. For exemple, if the rpart devide data into 3 classes, I want to divide my data onto this three subsets such that I know that row n°1 is in subset 1, row n°2 in subset 3, etc. I can't find how could I get this information from the results of rpart object?

tree.res &lt;- rpart(x ~ ., data, method="class", parms=list(split = "gini"))


I know that I can retrieve the results of this classification as follows:

plot(tree)    #plot the tree
text(tree)
printcp(tree) #Displays CP table for Fitted Rpart Object
predict(tree) #displays prediction results of x variable


How can I get the information on the segmentation of my data set? As first attempt I used : 

predict(tree, type = "vector")


Is this a correct approach?
I found an answer to my question using the package partykit, I post it to help others.

tree_party &lt;- as.party(tree) #coercing the rpart.object into partykit

tree_fit &lt;- fitted(tree_party) #a two-column data.frame with the fitted node numbers and the observed responses on the training data.

tree_pred &lt;- predict(tree_party, newdata = data, type = "node")