X <- rbind(matrix(rnorm(500, mean = 0, sd = 0.3), ncol = 2),
matrix(rnorm(500, mean = 1, sd = 0.3), ncol = 2),
matrix(rnorm(500, mean = -1, sd = 0.3), ncol = 2))
colnames(X) <- c("x", "y")
cl <- kmeanspp(X, 3)
plot(X, col = cl$cluster)
points(cl$centers, col = 1:3)
grid()
Run the code above in your browser using DataLab