R中的等大小聚类

时间:2018-02-26 02:43:30

标签: r cluster-analysis

我希望以距离矩阵的形式拥有相同大小的3个聚类,总共1000个观测值。以下是为简单起见而进行的5次观察的样本数据。

    1                  2                3                4           5
1   0             302.0366182    1802.347771    1929.003625      4152.862153
2   302.0366182      0           1502.097742     1629.91035      3966.183353
3   1802.347771   1502.097742          0        137.5130532      3439.08972
4   1929.003625    1629.91035    137.5130532         0           3470.441858
5   4152.862153   3966.183353     3439.08972    3470.441858          0

A <- as.dist(as(Clustering, "matrix"))

Clustering <- scale(Clustering) # standardize variables

# Ward Hierarchical Clustering
d <- dist(Clustering, method*emphasized text* = "euclidean") # for a distance matrix
fit <- hclust(d, method="ward.D2") 
plot(fit) # display dendogram
cutree(fit, k=3) # cut tree into 3 clusters
# draw dendogram with red borders around the 3 clusters 
rect.hclust(fit, k=3, border="red") 

如何获得相同大小的群集?

0 个答案:

没有答案