Learn R Programming

data.tree (version 0.2.0-3)

Prune: Prunes a tree. This function has side-effects, it modifies your data.tree structure!

Description

Prunes a tree. This function has side-effects, it modifies your data.tree structure!

Usage

Prune(node, pruneFun)

Arguments

node

The root of the sub-tree to be pruned

pruneFun

a function taking a Node as an argument, and returning TRUE if the Node and its descendants should be kept, FALSE otherwise.

Value

the number of nodes removed

Examples

Run this code
# NOT RUN {
data(acme)
Aggregate(acme, "cost", sum, "cost")
acme$Prune(function(x) x$cost > 700000)
print(acme, "cost")
# }

Run the code above in your browser using DataLab