-2

I am trying to draw a using the heatmap.2 with dendrograms using hierarchical cluster analysis. However I need two write different methods for each of the dendrograms. For y axis, I need to write Ward's Method, distance binary. And my X axis, Ward method distance squared euclidean.

Does anyone have any idea how to write the code for this?

lmo
  • 37,904
  • 9
  • 56
  • 69
  • please read [how to ask](http://stackoverflow.com/help/how-to-ask) and [mcve](http://stackoverflow.com/help/mcve) cause I'm missing the parts where you add what tried and what errors you're getting. – davejal Dec 15 '15 at 17:50

1 Answers1

1

You can manually specify the dendrograms like this:

library(gplots)
d1 <- as.dendrogram(hclust(dist(mtcars, method = "euclidean"), method = "ward.D"))
d2 <- as.dendrogram(hclust(dist(t(mtcars), method = "euclidean"), method = "ward.D2"))
heatmap.2(as.matrix(mtcars), Rowv=d1, Colv=d2)

See also ?dist and ?hclust for more options concerning the distance measure and clustering method.

lukeA
  • 53,097
  • 5
  • 97
  • 100