| clip.rpart {maptree} | R Documentation |
Reduces a prediction tree produced by rpart to a
smaller tree by specifying either a cost-complexity parameter,
or a number of nodes to which to prune.
clip.rpart (tree, cp=NULL, best=NULL)
tree |
object of class rpart. |
cp |
cost-complexity parameter. |
best |
number of nodes to which to prune. |
If both cp and best are not NULL, then
cp is used.
A minor enhancement of the existing prune.rpart to
incorporate the parameter best as it is used in
prune.tree. See example.
Pruned tree object of class rpart.
Denis White, white.denis@epa.gov
prune.tree,
rpart,
prune.rpart
library (rpart)
data (oregon.env.vars, oregon.border, oregon.grid)
draw.tree (clip.rpart (rpart (oregon.env.vars), best=7),
nodeinfo=TRUE, units="species", cases="cells", digits=0)
group <- group.tree (clip.rpart (rpart (oregon.env.vars), best=7))
names(group) <- row.names(oregon.env.vars)
map.groups (oregon.grid, group)
lines (oregon.border)
map.key (0.05, 0.65, labels=as.character(seq(6)),
size=1, new=FALSE, sep=0.5, pch=19, head="node")