Labels the current plot of the tree dendrogram with text.
# S3 method for rpart
text(x, splits = TRUE, label, FUN = text, all = FALSE,
pretty = NULL, digits = getOption("digits") - 3, use.n = FALSE,
fancy = FALSE, fwidth = 0.8, fheight = 0.8, bg = par("bg"),
minlength = 1L, …)
fitted model object of class "rpart"
. This is assumed to be the result
of some function that produces an object with the same named
components as that returned by the rpart
function.
logical flag. If TRUE
(default), then the splits in the tree are
labeled with the criterion for the split.
For compatibility with rpart2
, ignored in this version (with
a warning).
the name of a labeling function, e.g. text
.
Logical. If TRUE
, all nodes are labeled, otherwise just
terminal nodes.
the length to use for factor labels. A value of 1 causes them to be
printed as ‘a’, ‘b’, …..
Larger values use abbreviations of the label names.
See the labels.rpart
function for details.
an alternative to the minlength
argument, see
labels.rpart
.
number of significant digits to include in numerical labels.
Logical. If TRUE
, adds to label
(\#events level1/ \#events level2/etc. for class
,
n
for anova
, and \#events/n for poisson
and exp
).
Logical. If TRUE
, nodes are represented by ellipses (interior nodes)
and rectangles (leaves) and labeled by yval
. The edges connecting the
nodes are labeled by left and right splits.
Relates to option fancy
and the width of the ellipses and rectangles.
If fwidth < 1
then it is a scaling factor (default = 0.8). If
fwidth > 1
then it represents the number of character widths
(for current graphical device) to use.
Relates to option fancy
and the height of the ellipses and rectangles.
If fheight <1
then it is a scaling factor (default = 0.8). If
fheight > 1
then it represents the number of character heights
(for current graphical device) to use.
The color used to paint the background to annotations if fancy = TRUE
.
Graphical parameters may also be supplied as arguments to this
function (see par
). As labels often extend outside the plot
region it can be helpful to specify xpd = TRUE
.
the current plot of a tree dendrogram is labeled.
# NOT RUN {
freen.tr <- rpart(y ~ ., freeny)
par(xpd = TRUE)
plot(freen.tr)
text(freen.tr, use.n = TRUE, all = TRUE)
# }
Run the code above in your browser using DataLab