Navigation
Appearance

How to make a progress bar in R

DavidMSmith19 Mar 2009 · 1 min read
How to make a progress bar in R
Illustrative image generated with OpenAI gpt-image-1.

If you’re writing a function that you expect to take a long time to complete, you might want to give feedback to the user (or even just to yourself, during the development phase) that the function is actually still running and hasn’t simply hung.  The obvious solution is to include a statement like

See more SmartData Collective in your Google results.Add as sourceFollow

cat(iter/totaliters,”% complete…”)

in the loop. However, if you’re using anything other than the console version of R, the R GUI will hold any such output until the function completes, defeating the purpose. Mark Heckmann explains how you can turn off this “console buffering” feature so that you can see the progress output.  But then he goes one better: how about building a graphical progress bar?  See his post for a neat example of building such GUI elements with Tcl/Tk.

“R” you ready? Monitoring the function progress with a progress bar

Filed underr
Share this article

More on data mining

Find a perspective.

Saved for later.

Stored on this device only. Nothing is sent to SmartData.

    Nothing saved yet. Use “Save” on any article to keep it here.