progressBar: Progress Bars

progressBarR Documentation

Progress Bars

Description

Generalized progress bars, with 3 default flavours.

Usage

progressBar(name = names(progressBars), ...)

# declare a new progress bar
setProgressBarMethod(name, definition)

## S3 method for class 'progressBar'
close(con, ...)

Arguments

name

character string, which kind of progress bar to make or set a method. By default, one of "txt", "win" (Windows exclusive), and "tk".

...

Further arguments passed to other methods.

definition

a function that will create a progress bar corresponding to name.

con

progress bar to be closed.

Value

A "progressBar" object.

See Also

txtProgressBar

tkProgressBar

Examples

# if we use 'tryCatch', we can make use 'finally' to guarantee the progress bar
# is closed, regardless of signalling an error or user interupt. not entirely
# useful in this example, but it can be in longer, more complicated situations
tryCatch({
    pb <- progressBar(if (.Platform$OS.type == "windows")
        "win"
    else "txt", max = 20, style = 3)
    for (i in 1:20) {
        Sys.sleep(0.05)
        pb$increment()
    }
}, finally = {
    close(pb)
})

ArcadeAntics/essentials documentation built on Nov. 7, 2024, 4:33 p.m.