Я пытался выяснить, почему я вижу только один из двух графиков с нанесением точек () .
set.seed(0)
SSE <- rep(0, 10)
for (i in 1:10){
km.out <- kmeans(x = iris[,1:4], centers = 3, nstart = i)
SSE[i] <- km.out$tot.withins
}
plot(1:10, SSE, xlab = "k", ylab = "SSE", type = "b")
km.out$cluster
plot(iris[,1:2], col=(km.out$cluster+1), main="Best solution k = 3", xlab="x1", ylab="x2")
points(km.out$centers, col = 1:2, pch = 8, cex = 2)
plot(iris[,3:4], col=(km.out$cluster+1), main="Best solution k = 3", xlab="x1", ylab="x2")
points(km.out$centers, col = c3:4, pch = 8, cex = 2) # didn't work, not sure why
Первый график имеет точки.
![First plot](https://i.stack.imgur.com/CSEjC.png)
Второй участок без точек.
![Second plot](https://i.stack.imgur.com/Iz0JU.png)
Кто-нибудь знает, что я делаю не так?