progressBar {time}R Documentation

Draw and update a progress bar

Description

progressBar is initially called to draw the framework of the progress bar, then called during each iteration to update the number of bars, if needed.

The return value of progressBar should always be stored, then passed as the prev argument to the next call to progressBar.

Usage

progressBar(prop = 0, prev = 0)

Arguments

prop Specify the proportion of progress accomplished.
prev The number of bars already drawn, the return value prev obtained from the last call to progressBar.

Value

The number of bars drawn already, to be passed as the prev argument to the next call to progressBar.

Note

The current line of the terminal needs to be empty for progressBar to be drawn properly. Just make sure the last printed character was an end of line character, "\n".

Another assumption that progressBar makes is that it will be the only thing drawing to the terminal during the duration of calls to it. For proper appearance, no other drawing to the terminal should be done until progressBar is called with prop >= 1, which it takes as the signal that the analysis task is complete.

Author(s)

Toby Dylan Hocking <tobob@berkeley.edu>

Examples

n <- 5000
prev <- progressBar()
for( i in 1:n ) {
    #TimeConsumingAnalysisTask
    prev <- progressBar(i/n,prev)
}

[Package time version 1.0 Index]