我有一个数据集(已经缩放),总共包含 8 列:
- 第一列指示每个观察所属的分配集群,
- 以及 7 个因变量(每个变量在不同的列中)。
我想通过 R 中的坐标图开发聚类可视化,就像下面的博客 ( http://blog.datascienceheroes.com/short-lesson-on-cluster-analysis/ ) 中所示。
谁能帮我解决这个问题?
我有一个数据集(已经缩放),总共包含 8 列:
我想通过 R 中的坐标图开发聚类可视化,就像下面的博客 ( http://blog.datascienceheroes.com/short-lesson-on-cluster-analysis/ ) 中所示。
谁能帮我解决这个问题?
很多选择。你可以做
library(GGally)
ggparcoord(aggregate(mtcars, list(as.factor(cutree(hclust(dist(mtcars)), k = 4))), mean), columns=-1, groupColumn=1)
或者
library(parcoords)
parcoords(
aggregate(mtcars, list(cutree(hclust(dist(mtcars)), k = 4)), mean),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "Group.1")
)
parcoords(
transform(mtcars, cluster = cutree(hclust(dist(mtcars)), k = 4)),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "cluster")
)
你有你需要的功能的代码(plot_clus_coord
)在这里。