title: Print outputs in foreach loop in R
body: <p>I have been trying to get some output displayed from the foreach loop R. A reproducible example is </p>
  
  <pre><code>cl &lt;- makeCluster(2)
  registerDoParallel(cl)
  
  
  ptm1 &lt;- proc.time()
  foreach (i = 1:50, .packages = c("MASS"), .combine='+') %dopar% {
    ginv(matrix(rexp(1000000, rate=.001), ncol=1000))
    if (i &gt;49){
      cat("Time taken", proc.time() - ptm1)
    }
  }
  </code></pre>
  
  <p>I expect the time taken to be displayed. But, this does not display anything. Can you please suggest ways of capturing the messages in the foreach loop and displaying at the end of the loop. </p>