Function to perform K-means step by step and save iterations
Source:R/kmeans_iterative.R
kmeans_iterative.RdThis function performs K-means clustering but saves the cluster assignment and centers for each iteration of the algorithm.
Arguments
- x
numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns).
- centers
either a numeric value for k or a k by ncol(x) matrix of the initial centers.
- max_iter
maximum number of iterations before stopping if convergence doesn't occur first.