handler_progress: Progression Handler: Progress Reported via 'progress'...

View source: R/handler_progress.R

handler_progressR Documentation

Progression Handler: Progress Reported via 'progress' Progress Bars (Text) in the Terminal

Description

A progression handler for progress::progress_bar().

Usage

handler_progress(
  format = NULL,
  show_after = 0,
  intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
  target = "terminal",
  type = c("default", "steps", "percent", "time"),
  ...
)

Arguments

format

(character string) The format of the progress bar. If NULL, the format is determined by the type argument.

show_after

(numeric) Number of seconds to wait before displaying the progress bar.

intrusiveness

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

target

(character vector) Specifies where progression updates are rendered.

type

(character) The type of progress bar to display, which controls the default format passed to progress::progress_bar(). If "default", the format string is ":spin [:bar] :percent :message". If "steps", the format string is ":spin [:bar] :current/:total :message". If "percent", the format string is ":spin [:bar] :percent :message". If "time", the format string is "[:elapsed] :spin [:bar] :percent [:current/:total] (ETA: :eta) :message". For the meaning of these format variables, see progress::progress_bar. This argument is ignored if format is explicitly specified.

...

Additional arguments passed to progress::progress_bar() and make_progression_handler().

Value

A function of class progression_handler that takes a progression condition as its first and only argument.

Requirements

This progression handler requires the progress package.

Appearance

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

library(progressr)
handlers("progress")
y <- slow_sum_p(1:25)

handler_progress-default.svg

library(progressr)
handlers(handler_progress(complete = "#"))
y <- slow_sum_p(1:25)

handler_progress-complete.svg

library(progressr)
handlers(handler_progress(type = "steps"))
y <- slow_sum_p(1:25)

handler_progress-type-steps.svg

library(progressr)
handlers(handler_progress(type = "percent"))
y <- slow_sum_p(1:25)

handler_progress-type-percent.svg

library(progressr)
handlers(handler_progress(type = "time"))
y <- slow_sum_p(1:25)

handler_progress-type-time.svg

library(progressr)
handlers(handler_progress(format = ":spin [:bar] :percent :message"))
y <- slow_sum_p(1:25)

handler_progress-format-1.svg

library(progressr)
handlers(handler_progress(format = ":percent [:bar] :eta :message"))
y <- slow_sum_p(1:25)

handler_progress-format-2.svg

Examples

if (requireNamespace("progress", quietly = TRUE)) {

  handlers(handler_progress(format = ":spin [:bar] :percent :message"))
  with_progress({ y <- slow_sum_p(1:10) })
  print(y)
  
}

progressr documentation built on July 4, 2026, 1:06 a.m.