ggplot2聚类
作者:
可能性之兽 | 来源:发表于
2023-10-20 16:28 被阅读0次clusters <- hclust(dist(USArrests), "ave")
# reshaping USArrests
df <- data.frame(
State = rownames(USArrests)[row(USArrests)],
variable = colnames(USArrests)[col(USArrests)],
value = unname(do.call(c, USArrests))
)
g <- ggplot(df, aes(variable, State, fill = value)) +
geom_raster()
g + scale_y_dendrogram(hclust = clusters)
![](https://img.haomeiwen.com/i23627621/857eef6060389073.png)
image.png
Position Guides • ggh4x --- • ggh4x (teunbrand.github.io)
本文标题:ggplot2聚类
本文链接:https://www.haomeiwen.com/subject/eyvkidtx.html
网友评论