Below is a kmeans implementation, plotted with ggplot2. To change the y label values (because they are large, they are automatically formatted to scientific type i.e. exponential powers of n). To ‘unpower’ the values, you need to load the scales library and add the necessary in ggplot’s scale_y_continuous.