Cluster analysis in R: determine the optimal number of clusters

后端 未结 7 2051
星月不相逢
星月不相逢 2020-11-22 10:28

Being a newbie in R, I\'m not very sure how to choose the best number of clusters to do a k-means analysis. After plotting a subset of below data, how many clusters will be

7条回答
  •  天命终不由人
    2020-11-22 10:34

    It's hard to add something too such an elaborate answer. Though I feel we should mention identify here, particularly because @Ben shows a lot of dendrogram examples.

    d_dist <- dist(as.matrix(d))   # find distance matrix 
    plot(hclust(d_dist)) 
    clusters <- identify(hclust(d_dist))
    

    identify lets you interactively choose clusters from an dendrogram and stores your choices to a list. Hit Esc to leave interactive mode and return to R console. Note, that the list contains the indices, not the rownames (as opposed to cutree).

提交回复
热议问题