|
层次聚类 (hclust() ):
n <- seq(1 ,50 ,by = 4)
(x <- USArrests [n,]) # p r i n t ( )
hc1 <- hclust( dist (x) , method = "complete")
hc3 <- hclust( dist (x) , method = "ave")
layout(matrix(c(1 ,1 ,2 ,3) ,nrow = 2,byrow = T))
plot(hc1 ); plot(hc2 ); plot(hc3)
聚类过程中我们可能只需要对象的分类信息,那么使用 cutree() 函数也是不错的选择:
cutree(hc , k = 1:3)
当然还有专做聚类的包:cluster
library ( cluster )
clusplot ( x, pam(x, 2)$clustering ) |
|