| clip.rpart {maptree} | R Documentation |
Prunes an Rpart Classification or Regression Tree
Description
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.
Usage
clip.rpart (tree, cp=NULL, best=NULL)
Arguments
tree |
object of class |
cp |
cost-complexity parameter. |
best |
number of nodes to which to prune. |
If both cp and best are not NULL, then
cp is used.
Details
A minor enhancement of the existing prune.rpart to
incorporate the parameter best as it is used in the
(now defunct) prune.tree function in the old tree
package. See example.
Value
Pruned tree object of class rpart.
Author(s)
Denis White
See Also
Examples
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")
[Package maptree version 1.4-8 Index]