rect.hclust {mva} | R Documentation |
Draw Rectangles Around Hierarchical Clusters
Description
Draws rectangles around the branches of a dendrogram highlighting the corresponding clusters. First the dendrogram is cut at a certain level, then a rectangle is drawn around selected branches.
Usage
rect.hclust(hclust.obj, k=NULL, which=NULL, x=NULL, y=NULL,
border=2, cluster=NULL)
Arguments
hclust.obj |
an object of the type produced by |
k , h |
Scalar. Cut the dendrogram such that either exactly
|
which , x |
A vector selecting the clusters around which a
rectangle should be drawn. |
border |
Vector with border colors for the rectangles. |
cluster |
Optional vector with cluster memberships as returned by
|
Value
(Invisibly) returns a list where each element contains a vector of data points contained in the respective cluster.
See Also
hclust
, identify.hclust
Examples
library(mva)
data(USArrests)
hca <- hclust(dist(USArrests))
plot(hca)
rect.hclust(hca, k=3, border="red")
x <- rect.hclust(hca, h=50, which=c(2,7), border=3:4)
x