7

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?

mynameisJEFF
  • 4,073
  • 9
  • 50
  • 96
  • 1
    A [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) would help here, but if you know which objects fall w/i a given cluster, can't you just perform another `hclust` on just those objects & plot that? – gung - Reinstate Monica Sep 13 '13 at 15:36

1 Answers1

6

You could convert your hclust object into a dendrogram and use cut (see ?cut.dendrogram for details):

hc <- hclust(dist(USArrests), "ave")
plot(hc)

enter image description here

## 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))

enter image description here

sgibb
  • 25,396
  • 3
  • 68
  • 74