require(graphics)
# ?hclust
hc <- hclust(dist(USArrests), "ave")
# hc <- hclust(dist(USArrests), 'complete') dist(USArrests)
plot(hc)
plot(hc, hang = -1)
plot(as.dendrogram(hc), horiz = TRUE) # 横向き
par(mar = c(3, 1, 0, 9)) # 幅調整
plot(as.dendrogram(hc), horiz = TRUE)
library("dendextend")
##
## Welcome to dendextend version 0.12.2
##
## Type ?dendextend to access the overall documentation and
## vignette('dendextend') for the package vignette.
## You can execute a demo of the package via: demo(dendextend)
##
## More information is available on the dendextend project web-site:
## https://github.com/talgalili/dendextend/
##
## Contact: <tal.galili@gmail.com>
## Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues
##
## To suppress the this message use:
## suppressPackageStartupMessages(library(dendextend))
##
##
## Attaching package: 'dendextend'
##
## 以下のオブジェクトはマスクされています (from 'package:stats') :
##
## cutree
dend <- color_branches(hc, k = 3)
## Loading required package: colorspace
plot(dend, horiz = TRUE) # color