View source: R/loading-animations.R
progressbar | R Documentation |
Creates an animated progress bar
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"), ...)
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 |
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: ^.*?[.?][.*?][.?].*$
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.