title: Saving multiple outputs of foreach dopar loop
body: <p>I would like to know if/how it would be possible to return multiple outputs as part of <code>foreach dopar</code> loop.</p>
  
  <p>Let's take a very simplistic example. Let's suppose I would like to do 2 operations as part of the <code>foreach</code> loop, and would like to return or save the results of both operations for each value of <code>i</code>.</p>
  
  <p>For only one output to return, it would be as simple as:</p>
  
  <pre><code>library(foreach)
  library(doParallel)
  cl &lt;- makeCluster(3)
  registerDoParallel(cl)
  
  oper1 &lt;- foreach(i=1:100000) %dopar% {
      i+2
  }
  </code></pre>
  
  <p><code>oper1</code> would be a list with 100000 elements, each element is the result of the operation <code>i+2</code> for each value of i.</p>
  
  <p>Suppose now I would like to return or save the results of two different operations separately, e.g. <code>i+2</code> and <code>i+3</code>. I tried the following:</p>
  
  <pre><code>oper1 = list()
  oper2 &lt;- foreach(i=1:100000) %dopar% {
      oper1[[i]] = i+2
      return(i+3)
  }
  </code></pre>
  
  <p>hoping that the results of <code>i+2</code> will be saved in the list <code>oper1</code>, and that the results of the second operation <code>i+3</code> will be returned by <code>foreach</code>. However, nothing gets populated in the list <code>oper1</code>! In this case, only the result of <code>i+3</code> gets returned from the loop.</p>
  
  <p>Is there any way of returning or saving both outputs in two separate lists?</p>