as.Node.rpart: Convert an 'rpart' object to a 'data.tree' structure

Description Usage Arguments Value See Also Examples

View source: R/node_conversion_rpart.R

Description

Convert an rpart object to a data.tree structure

Usage

1
2
## S3 method for class 'rpart'
as.Node(x, digits = getOption("digits") - 3, use.n = FALSE, ...)

Arguments

x

the rpart object to be converted

digits

the number of digits to be used for numeric values in labels

use.n

logical. Add cases to labels, see text.rpart for further information

...

any other argument to be passed to generic sub implementations

Value

a data.tree object. The tree contains a field rpart.id which references back to the original node id in the row names of the rpart object.

See Also

Other as.Node: as.Node.data.frame(), as.Node.dendrogram(), as.Node.list(), as.Node.phylo(), as.Node()

Examples

1
2
3
4
if (require(rpart)) {
   fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
   as.Node(fit)
}

Example output

Loading required package: rpart
                levelName
1 Start>=8.5             
2  ¦--Start>=14.5        
3  ¦   ¦--absent         
4  ¦   °--Age< 55        
5  ¦       ¦--absent     
6  ¦       °--Age>=111   
7  ¦           ¦--absent 
8  ¦           °--present
9  °--present            

data.tree documentation built on Aug. 3, 2020, 5:12 p.m.