January 2010

Handy Apply-based R Progress Bars

In a funny congruence with my post on R progress bars, Mark Heckmann just posted about some wrappers for the apply functions in R. He wrote up some functions that imitate sapply, lapply and apply but automatically add a progress bar so you can monitor the progress. They work very nice since you can just substitute his apply_pb‘s in place of R’s standard apply‘s. He says it’s a bit of a performance drag but after testing a bit it looks like they really shouldn’t add much overhead at all if there’s any major calculations inside the loop. Very handy.

Programmer
R

Comments (0)

Permalink

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] numberSteps

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.

Programmer
R

Comments (2)

Permalink