title: Return multiple lists with foreach
body: <p>I am doing some kmeans clustering analysis. Example:</p>
  <pre><code>library(tidyverse)
  library(foreach)
  
  my_diamonds &lt;- diamonds %&gt;% select_if(is.numeric) %&gt;% scale %&gt;% as.data.frame
  try_centers &lt;- seq(from = 3, to = 12, by = 1)
  
  wss_list &lt;- foreach(k = try_centers) %do% { # forget parallel processing with this size of data not enough ram
    print(k) # progress bar
    hw = kmeans(my_diamonds, centers = k, iter.max = 20, nstart = 3, algorithm = 'Hartigan-Wong') 
  }
  
  wss &lt;- lapply(wss_list, function(i) i$tot.withinss) %&gt;% unlist()
  plot(try_centers, wss)
  </code></pre>
  <p>This returns a within sum of squares variance plot:
  <a href="https://i.stack.imgur.com/M6eF9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M6eF9.png" alt="enter image description here" /></a></p>
  <p>But I would like to compare with two other algorithms in kmeans. Tried:</p>
  <pre><code>wss_list &lt;- foreach(k = try_centers) %do% { # forget parallel processing with this size of data not enough ram
    print(k) # progress bar
    hw = kmeans(my_diamonds, centers = k, iter.max = 20, nstart = 3, algorithm = 'Hartigan-Wong') 
    lloyd = kmeans(my_diamonds, centers = k, iter.max = 20, nstart = 3, algorithm = 'Lloyd')
    mac = kmeans(my_diamonds, centers = k, iter.max = 20, nstart = 3, algorithm = 'MacQueen')
  }
  
  wss &lt;- lapply(wss_list, function(i) i$tot.withinss) %&gt;% unlist()
  plot(try_centers, wss)
  </code></pre>
  <p>This does return a plot, but which one am I looking at?! MaQueen? Lloyd?</p>
  <p>How can I structure this to run kmeans with the three algorithms on each iteration and then plot on one chart each of the 3?</p>