Debian Codegraph @

inst/examples/example_ggdendrogram.R

raw
1 ### Demonstrate ggdendrogram
2
3 library(ggplot2)
4 hc <- hclust(dist(USArrests), "ave")
5
6 # Demonstrate plotting directly from object class hclust
7 p <- ggdendrogram(hc, rotate = FALSE)
8 print(p)
9 ggdendrogram(hc, rotate = TRUE)
10
11 # demonstrate converting hclust to dendro using dendro_data first
12 hcdata <- dendro_data(hc)
13 ggdendrogram(hcdata, rotate = TRUE, size = 2) +
14 labs(title = "Dendrogram in ggplot2")