我在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])
答案 0 :(得分:1)
如果您对""" comment here, can be multiple lines"""
的优化结果感兴趣,可以在NbClust
中找到它,其中每个数字是数据矩阵中各行的簇编号。
例如
nc$Best.partition
表示20x10数据矩阵。