Description Usage Format Details Examples
Creates a progress bar object by calling the new
function. Progress
bar object may be updated at each loop iteration by calling the object's
update
function. See below the different parameters which may be
passed while creating the progress bar for further instructions.
1 |
An object of class R6ClassGenerator
of length 24.
- max A numerical variable, the total number of iterations. Used to
calculate percentage of progress and estimated time available if any value
greater than 0 is provided. Default value is 0.
- format A character variable, the console output that will be made
by calling the update
function of the progress bar object. Tokens
can be used in this string :
:bar / Displays the progress bar
:current / Displays the current index
:total / Displays the maximal index
:shorttotal / Displays the maximal index, shortened (ie. 1m, 10k, etc.)
:percent / Displays the progress percentage
:elapsed / Displays the elapsed time, shortened formatting
:elapsedexact / Displays the elapsed time, exact hh:mm:ss.ss format
:eta / Displays the estimated available time (ETA), shortened formatting
:etaexact / Displays the ETA, exact hh:mm:ss.ss format
:tet / Displays the total estimated time (TET), shortened formatting
:tetexact / Displays the TET, exact hh:mm:ss.ss format
See examples for more information on how to use the format parameter.
- cursors A character vector of length 2, containing the progress bar
complete state character (first character of vector) and the progress bar
incomplete state character (second). Default value is c('#',' '), which
will output a |##### | like progress bar.
- ini A numerical variable, The initial index value. Can not be set
to a negative value to prevent division by zero during progress. Default
value is 1.
- barlength A numerical variable, the length in characters of the
actual progress bar. Should be set between 0 (no bar displayed) and 100.
Default value is 10.
- outputpace A numerical variable, the minimal delta index between two
console updates. If set to 0, this value will automatically be set to 0.01
of the total iterations count to maximize performance. Default value is 0.
- mindelay A numerical variable, the minimal delay in milliseconds
between two console updates. Default value is 0.1.
- spiningcursor A logical variable. If TRUE
, an animated cursor will
be shown in the progress bar. Default value is TRUE
.
Returns a progress bar object with initial values set to passed parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # The total iterations in each loop should be set to at least 100000 to see
# the progress bar. The examples below are ran with a value of 100 to make
# R code checking faster.
# n = 100000 # Uncomment for testing
n = 100 # Remove for testing
# A simple progress bar can be created by using the pb \code{new} function :
my_pb = pb$new(n)
# If total number of iterations is not known, passing no parameter is possible :
my_pb = pb$new()
# Once the progress bar object is created, the \code{update} function will
# provoke values update of the object, as well as console output refresh :
for(i in 1:n) {
Sys.sleep(0.001)
my_pb$update()
}
# Several formatting styles can be tried. Tokens will automatically be
# replaced when outputting the progress bar onto the console :
my_pb = pb$new(n,
format = ':current/:total :bar:percent Elapsed: :elapsedexact ETA: :etaexact Total: :tetexact')
for(i in 1:n) {
Sys.sleep(0.001)
my_pb$update()
}
my_pb = pb$new(n,
format = 'Progress: :bar:percent Elapsed: :elapsed ETA: :eta Total: :tetexact')
for(i in 1:n) {
Sys.sleep(0.001)
my_pb$update()
}
# See vignettes for more information.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.