km = kmeans(FourA,3) 公里$集群 [1] 1 1 1 2 1 1 2 2 2 2 3 2 ...
如何使用km $群集矢量创建3个新阵列,以便我可以使用不同的字符/颜色绘制具有三个群集的图形?
答案 0 :(得分:0)
供您参考
x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
cl <- kmeans(x, 3, nstart = 25)
plot(x, col = cl$cluster)
points(cl$centers, col = 1:3, pch = 8)