handler_txtprogressbar: Progression Handler: Progress Reported as Plain Progress Bars...

View source: R/handler_txtprogressbar.R

handler_txtprogressbarR Documentation

Progression Handler: Progress Reported as Plain Progress Bars (Text) in the Terminal

Description

A progression handler for utils::txtProgressBar().

Usage

handler_txtprogressbar(
  char = "=",
  style = 3L,
  file = stderr(),
  intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
  target = "terminal",
  ...
)

Arguments

char

(character) The symbols to form the progress bar for utils::txtProgressBar(). Contrary to txtProgressBar(), this handler supports also ANSI-colored symbols.

style

(integer) The progress-bar style according to utils::txtProgressBar().

file

(connection) A base::connection to where output should be sent.

intrusiveness

(numeric) A non-negative scalar on how intrusive (disruptive) the reporter to the user.

target

(character vector) Specifies where progression updates are rendered.

...

Additional arguments passed to make_progression_handler().

Appearance

Below are a few examples on how to use and customize this progress handler. In all cases, we use handlers(global = TRUE).

handlers("txtprogressbar")
y <- slow_sum(1:25)

handler_txtprogressbar-default.svg

handlers(handler_txtprogressbar(style = 1L))
y <- slow_sum(1:25)

handler_txtprogressbar-style-1.svg

handlers(handler_txtprogressbar(style = 3L))
y <- slow_sum(1:25)

handler_txtprogressbar-style-3.svg

handlers(handler_txtprogressbar(char = "#"))
y <- slow_sum(1:25)

handler_txtprogressbar-char.svg

handlers(handler_txtprogressbar(char = "<>"))
y <- slow_sum(1:25)

handler_txtprogressbar-char-width-2.svg

handlers(handler_txtprogressbar(char = cli::col_red(cli::symbol$heart)))
y <- slow_sum(1:25)

handler_txtprogressbar-char-ansi.svg

Examples

handlers("txtprogressbar")

with_progress({ y <- slow_sum(1:10) })
print(y)

progressr documentation built on Aug. 11, 2023, 1:07 a.m.