title: append rows to dataframe using foreach package
body: <p>I have a problem with appending values to a data frame using parallel processing.</p>
  
  <p>I have a function that will do some calculation and return a dataframe, including these calculation is a random sampling.</p>
  
  <p>so what i did is :</p>
  
  <pre><code>randomizex &lt;- function(testdf)
  {
      foreach(ind=1:1000)%dopar%
      {
        testdf$X = sample(testdf$X,nrow(testdf), replace=FALSE)
        fit = lm(X ~ Y, testdf)
        newdf &lt;- rbind(newdf, data.frame(pc=ind, err=sum(residuals(fit)^2) ))
  
      }
  
  return(newdf)
  }
  resdf = randomizex(mydf)
  </code></pre>
  
  <p>when i view the result of <code>resdf</code>, it's empty</p>
  
  <p>if i replace <code>%dopar%</code> with <code>%do%</code> the result is calculated correctly but it's too slow ..</p>
  
  <p>is there anyway to boost this a bit ??</p>