<p>There's a CRAN package called <a href="https://cran.r-project.org/web/packages/knor/index.html" rel="noreferrer">knor</a> that is derived from a <a href="https://arxiv.org/abs/1606.08905" rel="noreferrer">research paper</a> that improves the performance using a memory efficient variant of Elkan's pruning algorithm. It's an order of magnitude faster than everything in these answers.</p>

<pre><code>install.packages("knor")
require(knor)
iris.mat &lt;- as.matrix(iris[,1:4])
k &lt;- length(unique(iris[, dim(iris)[2]])) # Number of unique classes
nthread &lt;- 4
kms &lt;- Kmeans(iris.mat, k, nthread=nthread)
</code></pre>
parallel k-means in R
<p>I am trying to understand how to parallelize some of my code using R. So, in the following example I want to use k-means to cluster data using 2,3,4,5,6 centers, while using 20 iterations. 
Here is the code: </p>

<pre><code>library(parallel)
library(BLR)

data(wheat)

parallel.function &lt;- function(i) {
    kmeans( X[1:100,100], centers=?? , nstart=i )
}

out &lt;- mclapply( c(5, 5, 5, 5), FUN=parallel.function )
</code></pre>

<p>How can we parallel simultaneously the iterations and the centers? 
How to track the outputs, assuming I want to keep all the outputs from k-means across all, iterations and centers, just to learn how?</p>