tile.tree: Add Class Barcharts to a Classification Tree Plot

View source: R/treemisc.R

tile.treeR Documentation

Add Class Barcharts to a Classification Tree Plot

Description

This computes the frequencies of level of var for cases reaching each leaf of the tree, and plots barcharts of the set of frequencies underneath each leaf.

Usage

tile.tree(tree, var, screen.arg = ascr + 1, axes = TRUE)

Arguments

tree

fitted object of class "tree".

var

a factor variable to be displayed: by default it is the response factor of the tree.

screen.arg

The screen to be used: default the next after the currently active screen.

axes

logical flag for drawing of axes for the barcharts.

Value

A matrix of counts of categories (rows) for each leaf (columns). The principal effect is the plot.

Author(s)

B. D. Ripley

See Also

tree.screens

Examples

data(fgl, package="MASS")
fgl.tr <- tree(type ~ ., fgl)
summary(fgl.tr)
plot(fgl.tr);  text(fgl.tr, all=TRUE, cex=0.5)
fgl.tr1 <- snip.tree(fgl.tr, node=c(108, 31, 26))
tree.screens()
plot(fgl.tr1)
text(fgl.tr1)
tile.tree(fgl.tr1, fgl$type)
close.screen(all = TRUE)

tree documentation built on Feb. 16, 2023, 10:10 p.m.

Related to tile.tree in tree...