Progress Bars in R

Recently, I've had a lot of time consuming tasks running in R where it's nice to know how the computer is doing. I usually just output the name of the current iteration or a dot or something but I finally decided I should figure out how to make a nice progress bar in R. It turns out it's really simple since it's already builtin with the txtProgressBar function. So you can do something like:

R:
  1. numberSteps<-10
  2. pb <- txtProgressBar(min = 0, max = numberSteps, style = 3)
  3. for(i in 1:numberSteps){
  4.   setTxtProgressBar(pb, i)
  5.   Sys.sleep(1)
  6. }
  7. close(pb)

A text progress bar in R

That's good enough for me but there's also winProgressBar for a fancy Windows progress bar and tkProgressBar (in the tcltk package) if you really want to get fancy.