How to show the progress of code in R?
<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). Here is an example. Thanks.</p>

<pre><code>require(Kendall)
mydata=matrix(rnorm(6000*300),ncol = 300)
result=as.data.frame(matrix(nrow = 6000,ncol = 2))
for (i in 1:6000) {
  abc=MannKendall(mydata[i,])
  result[i,1]=abc$tau
  result[i,2]=abc$sl
}
</code></pre>

<p>By the way, I find the link <a href="https://ryouready.wordpress.com/2009/03/16/r-monitor-function-progress-with-a-progress-bar/" rel="noreferrer">https://ryouready.wordpress.com/2009/03/16/r-monitor-function-progress-with-a-progress-bar/</a> very usefull. However, I do not know how to combine the code in the link with my own function. Anyone has an idea? Thanks. Here is the code from the above link.</p>

<pre><code>total &lt;- 20
# create progress bar
pb &lt;- txtProgressBar(min = 0, max = total, style = 3)
for(i in 1:total){
   Sys.sleep(0.1)
   # update progress bar
   setTxtProgressBar(pb, i)
}
close(pb)
</code></pre>