我怎么知道哪些观察属于哪个集群?

How do I know which observations belong to which cluster?

我 运行 R 中的层次聚类,我怎么知道哪个观察属于哪个聚类?谢谢!

 ### Hierarchical Clustering
 d <- dist(EMEA_2, method = "euclidean") # distance matrix
 fit <- hclust(d, method="complete") 

 ### Decide bet number of clusters 
 library(knitr)
 library(NbClust)

 nc<-NbClust(data = EMEA_2, distance = "euclidean", min.nc=2, max.nc=15, method = "complete", index = "db", alphaBeale = 0.1)

 groups <- cutree(fit, k=2) # cut tree into 2 clusters

 ### Get group means and number of frequencies within each cluster
 a2<-aggregate(EMEA_2, list(groups),mean)
 a4<-data.frame(Cluster = a2[,1], Freq = as.vector(table(groups)), a2[,-1])

如果您对 NbClust 的优化结果感兴趣,您会在 nc$Best.partition 中找到它,其中每个数字都是数据矩阵中相应行的簇号。

例如

> nc$Best.partition
 [1] 1 2 3 4 5 1 3 5 1 1 4 1 4 1 5 1 5 1 4 2

对于 20x10 数据矩阵。