prune: Cost-complexity pruning of a dpart object

View source: R/prune.r

pruneR Documentation

Cost-complexity pruning of a dpart object

Description

This function prunes a fitted dpart object based on either the standard error or number of splits required.

Usage

## S3 method for class 'dpart'
prune(tree, se, nsplits, ...)

## S3 method for class 'dpart'
prune(tree, se, nsplits, ...)

Arguments

tree

a legitimate tree object of class dpart.

...

arguments to be passed to or from other methods

se

numeric. A standard error used to prune.

nsplits

numeric. Number of splits to prune to.

Details

A new dpart object that is pruned based on the number of standard errors or number of splits.

References

Breiman, L., Friedman, J.H., Olshen, R.A. and Stone, C.J. (1984) Classification and Regression Trees. Wadsworth International.

See Also

dpart

Examples


# Load data
#data(yftdiet)  

# Load the prey taxa data
#data(PreyTaxonSort)

# Assigning prey colours for default palette
#val <- apc(x = yftdiet, preyfile = PreyTaxonSort, check = TRUE)
#node.colsY <- val$cols
#dietPP <- val$x   # updated diet matrix with Group assigned prey taxa codes

# Fitting the classification tree
#yft.dp <- dpart(Group ~ Lat + Lon + Year + Quarter + SST  + Length, 
#                   data = dietPP, weights = W, minsplit = 10,
#                                     cp = 0.001)
#yft.pr <- prune(yft.dp, se = 1)
#plot(yft.pr, node.cols = node.colsY)

pkuhnert/diet documentation built on June 10, 2025, 2:59 a.m.