[R] problem in labeling the nodes of tree drawn by rpart

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue Dec 8 22:48:36 CET 2009


Depending on your sample size, you might be able to just label the nodes 
by drawing a random sample from the variable names :-)

Frank

kaida ning wrote:
> 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

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list