Node {ModTools} | R Documentation |
Nodes and Splits in an rpart Tree
Description
The rpart
result object has a complex and compact design. This can make practical use tedious for occasional users as it is difficult to figure out how to access some specific information. The function Node()
is designed as accessor to the most important properties of a node, being a 'split' or a 'leaf' (aka. 'endnode'). It also serves as base for further convenience functions as e.g. LeafRates()
.
Usage
Node(x, node = NULL, type = c("all", "split", "leaf"), digits = 3)
Arguments
x |
fitted model object of class |
node |
integer vector, defining the nodes whose details are required. |
type |
one out of |
digits |
the number of digits for numeric values |
Details
Node()
returns detailed information for a single node in the tree. It reports all the data in the summary of a node, but with the option to provide a nodelist. The structure of the result is organised as a list.
Value
A list containing:
id |
int, id of the node |
vname |
character, one out of |
isleaf |
logical, |
nobs |
integer, number of observation in the node |
group |
character, the predicted class for the node |
ycount |
numeric, the number of observation per class in the node |
yprob |
numeric, the relative frequencies for the each class |
nodeprob |
the global probability for an observation to fall in the node |
complexity |
numeric, the complexity parameter for the node |
tprint |
character, the text to be printed |
Author(s)
Andri Signorell <andri@signorell.net>
See Also
Examples
r.rpart <- FitMod(Species ~ ., data=iris, fitfn="rpart")
# return Node nr. 3
Node(r.rpart, node=3)
r.rp <- FitMod(Type ~ ., data = d.glass, fitfn="rpart")
# return all the splits
Node(r.rpart, type="split")