title: How to show the progress of code in parallel computation in R?
body: <p>I am now dealing with a large dataset and some functions may take hours to process. I wonder how I can show the progress of the code through a progress bar or number(1,2,3,...,100). And I want to store the result as a data frame with two columns. Here is an example. Thanks.</p>
  
  <pre><code>require(foreach)
  require(doParallel)
  require(Kendall)
  
  cores=detectCores()
  cl &lt;- makeCluster(cores-1)
  registerDoParallel(cl)
  
  mydata=matrix(rnorm(8000*500),ncol = 500)
  result=as.data.frame(matrix(nrow = 8000,ncol = 2))
  pb &lt;- txtProgressBar(min = 1, max = 8000, style = 3)
  
  foreach(i=1:8000,.packages = "Kendall",.combine = rbind) %dopar%         
  {
    abc=MannKendall(mydata[i,])
    result[i,1]=abc$tau
    result[i,2]=abc$sl
    setTxtProgressBar(pb, i)
  }
  close(pb)
  stopCluster(cl)
  </code></pre>
  
  <p>However, when I run the code, I did not see any progress bar showing up and the result is not right. Is there any suggestion? Thanks.</p>