Description Usage Format Initialization Adding new entries Displaying the status bar Examples
This is an R port of a Fortran module that was used in the astrophysical codes SPEV and MRGENESIS.
1 |
An object of class R6ClassGenerator
of length 24.
An R6 object is initalized sing estatusbar$new()
with a no arguments. It should be called by the user when the task starts.
As the task progresses, the user can call the function add
to register the fraction of the task that has been completed. The routine add
has only one argument, the fraction (between 0 and 1) that is complete at current time.
At any point the user can call the display
function to draw the status bar in terminal. This function accepts the following arguments:
width = 40, text = NULL, perc = TRUE, eta = TRUE, digits=0
The width of the progress bar. The default values is 40 characters
A custom text string that can be shown next to the progress bar. By default no text is displayed.
Percentage display flag, by default set to TRUE. This controls whether the percentage of progress should be printed.
Estimated completion time display flag, by default set to TRUE. This controls whether the ETA should be printed.
Total number of digits to be used when printing seconds, by default set to 0. This allows the user to show fractions of a second.
1 2 3 4 5 6 7 8 | What follows is the typical usage case. The status bar is registered, and then 20 entries are added. Before each add the system sleeps for a random time interval (between 0 and 2 seconds). Afterward an entry is registered and the display is updated.
est <- estatusbar$new()
for (i in 1:20) {
Sys.sleep(2 * runif(1))
est$add(i / 20)
est$display()
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.