find.leaves: Find all descendant leaves of a node in an hclust tree

Description Usage Arguments Value Examples

Description

The function recursively finds all leaves that are descendants of a node in an hclust tree.

Usage

1

Arguments

ind

Index of the tree node. For an hclust tree of p leaves, -j denotes the jth leaf and k denotes the interior node formed at the kth merging in constructing the tree. The range of ind is {-1, ..., -p, 1,..., p-1} where p-1 is the number of interior nodes.

merge

A (p-1)-by-2 matrix that encodes the order of mergings in constructing the tree. merge uses the same notation for nodes and mergings in an hclust object. See hclust for details.

Value

Returns a sequence of indices for descendant leaves in the leaf set {1, ..., p}. Unlike the notation used in ind, we use positive integers to denote leaves here.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
hc <- hclust(dist(USArrests), "ave")
# Descendant leaves of the 10th leaf (should be iteself)
find.leaves(-10, hc$merge)

# Descendant leaves of the 10th interior node
find.leaves(10, hc$merge)

# Descendant leaves of the root (should be all leaves)
ind_root <- nrow(hc$merge)
all.equal(find.leaves(ind_root, hc$merge), hc$order)

## End(Not run)

rare documentation built on May 1, 2019, 9:17 p.m.