0
votes

Folks:

Is there a way to make a dendrogram generated from function like hclust() horizontal, without using the function as.dendrogram().

So not to loose the enhancement code (i.e, rect.hclust, xlab, ylab, etc.) developed for the original hclust dendrogram?

Thanks!

1

1 Answers

-1
votes

You can use the dendextend R package to get all of this functionality in more in dendrograms.

For example

library(dendextend)

dend <- USArrests %>%
   dist() %>%
   hclust(method = "ave") %>%
   as.dendrogram() %>% hang.dendrogram() %>% 
   color_branches(k = 5)

par(mar = c(2,2,1,8))
plot(dend, horiz = T)
rect.dendrogram(dend, k = 3, horiz = T)

enter image description here

More details: https://cran.r-project.org/web/packages/dendextend/vignettes/dendextend.html