Move! Average! Cluster! Move! Average! Cluster! …
oopt = ani.options(ani.height = 480, ani.width = 480, outdir = getwd(), interval = 2, nmax = 50, title = "Demonstration of the K-means Cluster Algorithm", description = "Move! Average! Cluster! Move! Average! Cluster! ...") ani.start() par(mar = c(3, 3, 1, 1.5), mgp = c(1.5, 0.5, 0)) cent = 1.5 * c(1, 1, -1, -1, 1, -1, 1, -1); x = NULL for (i in 1:8) x = c(x, rnorm(25, mean = cent[i])) x = matrix(x, ncol = 2) colnames(x) = c("X1", "X2") kmeans.ani(x, centers = 4, pch = 1:4, col = 1:4) ani.stop() ani.options(oopt)