1

Please see my previous question for details relating to test data and commands used to create a dendrogram: Using R to cluster based on euclidean distance and a complete linkage metric, too many vectors?

Here is a quick summary of my commands to make the dendrogram:

un_exprs <- as.matrix(read.table("sample.txt", header=TRUE, sep = "\t", row.names = 1, as.is=TRUE))
exprs <- t(un_exprs)
eucl_dist=dist(exprs,method = 'euclidean')
hie_clust=hclust(eucl_dist, method = 'complete')\
dend <- as.dendrogram(hie_clust)
plot(dend)

This makes a very nice dengrogram plot. However, lets say this dendrogram has 2 clusters... I want to get a text list of each element belonging to each of the 2 clusters. I'm assuming this is trivial, but I don't have enough experience with R for this to be intuitive. Thanks!

Community
  • 1
  • 1
jake9115
  • 3,964
  • 12
  • 49
  • 78

1 Answers1

3

You can compute this from the hclust return with stats::cutree

cutree(hie_clust,k=2)
scoa
  • 19,359
  • 5
  • 65
  • 80