subtree: subtrees

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/subtree.R

Description

Takes a subtree of a dendrogram object such as generated by hclust according to a prespecified number of clusters or a prespecified height.

Usage

1
subtree(tree, k = NULL, h = NULL)

Arguments

tree

The tree object which contains the attributes merge and height in the same way as an hclust object.

k

The number of clusters at which to cut.

h

The height at which to cut.

Details

Does the same as cutree with two differences: Firstly it gives back an entire tree object, i.e. an object with attributes merge, height, labels and order, as well as data, which contains the cluster ids. Secondly the cluster ids are chosen by the heights at which the clusters were built.

Value

An hclust object.

Author(s)

Alexander Pilhoefer

See Also

cutree

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
hc <- hclust(dist(USArrests), "ave")

hcs <- subtree(hc, k = 7)
hcs2 <- subtree(hc, h= 30)

attributes(hcs)
fluctile(table(hcs$data, cutree(hc, k=7)))

par(mfrow=c(1,3))
plot(hc)
plot(hcs)
plot(hcs2)

extracat documentation built on July 17, 2018, 5:05 p.m.

Related to subtree in extracat...