cluster presentation dendrogram alternative in r

浪尽此生 提交于 2019-12-02 18:36:54

You are describing a fairly typical way of going about cluster analysis:

  • Use a clustering algorithm (in this case hierarchical clustering)
  • Decide on the number of clusters
  • Project the data in a two-dimensional plane using some form or principal component analysis

The code:

hc <- hclust(dist(mtcars))
cluster <- cutree(hc, k=3)
xy <- data.frame(cmdscale(dist(mtcars)), factor(cluster))
names(xy) <- c("x", "y", "cluster")
xy$model <- rownames(xy)

library(ggplot2)
ggplot(xy, aes(x, y)) + geom_point(aes(colour=cluster), size=3)

What happens next is that you get a skilled statistician to help explain what the x and y axes mean. This usually involves projecting the data to the axes and extracting the factor loadings.

The plot:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!