labels.rpart: Create Split Labels For an Rpart Object

View source: R/labels.rpart.R

labels.rpartR Documentation

Create Split Labels For an Rpart Object


This function provides labels for the branches of an rpart tree.


## S3 method for class 'rpart'
labels(object, digits = 4, minlength = 1L, pretty, collapse = TRUE, ...)



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.


the number of digits to be used for numeric values. All of the rpart functions that call labels explicitly set this value, with options("digits") as the default.


the minimum length for abbreviation of character or factor variables. If 0 no abbreviation is done; if 1 single English letters are used, first lower case than upper case (with a maximum of 52 levels). If the value is greater than , the abbreviate function is used, passed the minlength argument.


an argument included for compatibility with the original Splus tree package: pretty = 0 implies minlength = 0L, pretty = NULL implies minlength = 1L, and pretty = TRUE implies minlength = 4L.


logical. The returned set of labels is always of the same length as the number of nodes in the tree.

If collapse = TRUE (default), the returned value is a vector of labels for the branch leading into each node, with "root" as the label for the top node.

If FALSE, the returned value is a two column matrix of labels for the left and right branches leading out from each node, with "leaf" as the branch labels for terminal nodes.


optional arguments to abbreviate.


Vector of split labels (collapse = TRUE) or matrix of left and right splits (collapse = FALSE) for the supplied rpart object. This function is called by printing methods for rpart and is not intended to be called directly by the users.

See Also


rpart documentation built on Oct. 10, 2023, 1:08 a.m.