Hi all, I used rpart to fit a model, where the covariates in the model are categorical variables. Then I plotted the tree (mytree) and used the command "text" to add labels to the tree. In the nodes of the tree, the values of the covariates are represented with a, b or c. Is there a way to show the real value(s) of the variable in the nodes instead of a, b or c ? I found that the command "labels(mytree,minlength=3)" can give me the desired label, but I don't know how to add it to the tree. Best, Kaida -------------- next part -------------- A non-text attachment was scrubbed... Name: tree.pdf Type: application/pdf Size: 32968 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091207/b9abc3a6/attachment-0002.pdf>
Hi all, I used rpart to fit a model, where the covariates are categorical variables. Then I plotted the tree (mytree) and used the command "text" to add labels to the tree. In the nodes of the tree, the values of the covariates are represented with a, b or c (tree attached). Is there a way to show the real value(s) of the variable in the nodes instead of a, b or c ? I found that the command "labels(mytree,minlength=3)" can give me the desired label, but I don't know how to add it to the tree. Best, Kaida -------------- next part -------------- A non-text attachment was scrubbed... Name: tree.pdf Type: application/pdf Size: 32968 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091208/b78abb50/attachment-0002.pdf>
Terry Therneau
2009-Dec-09 15:10 UTC
[R] problem in labeling the nodes of tree drawn by rpart
> In the nodes of the tree, the values of the covariates are represented > with a, b or c (tree attached).Try help('text.rpart'), and note the 'pretty' argument therein. There is often not enough room for long labels, and so the default is to do the severe truncation you speak of. Terry Therneau