draw.tree: Graph a Classification or Regression Tree

draw.treeR Documentation

Graph a Classification or Regression Tree

Description

Graph a classification or regression tree with a hierarchical tree diagram, optionally including colored symbols at leaves and additional info at intermediate nodes.

Usage

  draw.tree (tree, cex=par("cex"), pch=par("pch"), size=2.5*cex, 
      col=NULL, nodeinfo=FALSE, units="", cases="obs", 
      digits=getOption("digits"), print.levels=TRUE, 
      new=TRUE)

Arguments

tree

object of class rpart or tree.

cex

size of text, par parameter.

pch

shape of symbol at leaves, par parameter.

size

if size=0, draw terminal symbol at leaves else a symbol of size in cex units.

col

vector of colors from hsv, rgb, etc, or if NULL, then use rainbow.

nodeinfo

if TRUE, add a line at each node with mean value of response, number of observations, and percent deviance explained (or classified correct).

units

label for units of mean value of response, if regression tree.

cases

label for type of observations.

digits

number of digits to round mean value of response, if regression tree.

print.levels

if TRUE, print levels of factors at splits, otherwise only the factor name.

new

if TRUE, call plot.new.

Details

As in plot.rpart(,uniform=TRUE), each level has constant depth. Specifying nodeinfo=TRUE, shows the deviance explained or the classification rate at each node.

A split is shown, for numerical variables, as variable <> value when the cases with lower values go left, or as variable >< value when the cases with lower values go right. When the splitting variable is a factor, and print.levels=TRUE, the split is shown as levels = factor = levels with the cases on the left having factor levels equal to those on the left of the factor name, and correspondingly for the right.

Value

The vector of colors supplied or generated.

Author(s)

Denis White

See Also

rpart, draw.clust, map.groups

Examples

  library (rpart)
  data (oregon.env.vars)

  draw.tree (clip.rpart (rpart (oregon.env.vars), best=7), 
      nodeinfo=TRUE, units="species", cases="cells", digits=0)

maptree documentation built on April 6, 2022, 5:09 p.m.

Related to draw.tree in maptree...