I have 250 objects and I used h <- hclust(distance.matrix, method = "single")
to obtain a hclust
object. If I plot the dendrogram from h
, it is just a mess since there are too many objects and the labels just get squashed together.
Suppose I am interested in particular groups of cluster
Now, I know we can use cutree
to cut a tree, e.g., as resulting from hclust, into several groups by specifying the desired number(s) of groups.
But how can I obtain a dendrogram for those smaller groups of clusters in R separately?
You could convert your hclust
object into a dendrogram
and use cut
(see ?cut.dendrogram
for details):
hc <- hclust(dist(USArrests), "ave")
plot(hc)
## cut at height == 100
d <- cut(as.dendrogram(hc), h=100)
## cut returns a list of sub-dendrograms
d
#$upper
#'dendrogram' with 2 branches and 2 members total, at height 152.314
#
#$lower
#$lower[[1]]
#'dendrogram' with 2 branches and 16 members total, at height 77.60502
#$lower[[2]]
#'dendrogram' with 2 branches and 34 members total, at height 89.23209
par(mfrow=c(1, 2))
plot(d$lower[[1]])
plot(d$lower[[2]])
par(mfrow=c(1, 1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With