-5
我在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])
你的代碼在哪裏? – mtoto
@mtoto我剛剛編輯謝謝! –
看'str(nc)'''''''''''''''''''''''''''''''''''''''''stats :: kmeans'然後你可以用'nc $ clusters $'或者其他名稱來訪問它。 –