| clip.rpart | 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 |
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 the
(now defunct) prune.tree function in the old tree
package. See example.
Pruned tree object of class rpart.
Denis White
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.