progressbar {hgutils} | R Documentation |
Creates an animated progress bar
Description
Creates an animated progress bar
Usage
progressbar(
format = "[[|][|/-\\][ ]]",
width = 20,
refresh = 200,
n_iterations = NULL
)
render(object, ...)
## S3 method for class 'fraction_progressbar'
render(object, progress, show_progress = c("nothing", "percentage"), ...)
## S3 method for class 'iteration_progressbar'
render(
object,
progress,
show_progress = c("nothing", "percentage", "iteration"),
...
)
## S3 method for class 'progressbar'
render(object, show_progress = c("nothing", "percentage", "iteration"), ...)
Arguments
format |
character vector containing the format of the animation. See 'details' for more information. |
width |
progress bar width. |
refresh |
refresh rate in milliseconds of the animation. |
n_iterations |
optional parameter, specifies the number of total iterations. When updating the progress bar it is then sufficient to specify the current iteration number. |
object |
animated progress bar. |
... |
further arguments passed to or from other methods. |
progress |
either the iteration number (if n_iterations is set), or the progress fraction (in [0,1]). |
show_progress |
how to show the progress. Either not to show it (default),
show a percentage or if |
Details
The format of the progress bar is given by a character vector. It consists of 5 parts:
the left border of the progress bar consisting of 0 or more characters.
a pair of square brackets containing a single character which represents the loaded area.
a pair of square brackets containing 0 or more characters. These are animated on the border between the loaded and unloaded area.
a pair of square brackets containing a single character which represents the unloaded area.
the right border of the progress bar consisting of 0 or more characters.
The format follows the following regular expression: ^.*?[.?][.*?][.?].*$
Examples
## Not run:
# simple progressbar
bar = progressbar(format = "[[|][|/-\\][ ]]")
# fancy progressbar using UTF-8 codes
n_operations = 1000
bar2 = progressbar(format="\u25ba[\u2589][\u2580\u2584][\u3000]\u25c4", n_iterations=n_operations)
for(i in 1:n_operations) {
cat("\r", render(bar),sep="")
Sys.sleep(0.01)
}
## End(Not run)