Skip to contents

Creates a progress reporting function for use in loops or apply-style operations. Returns a no-op function if progressr is not available or disabled.

Usage

create_progressor(steps, enable = TRUE)

Arguments

steps

Integer specifying the total number of steps

enable

Logical indicating whether to enable progress reporting (default: TRUE)

Value

A function that signals progress when called. If progressr is not available or enable = FALSE, returns a no-op function.

Details

This function wraps progressr::progressor() with a fallback for when progressr is not available.

Examples

if (FALSE) { # \dontrun{
# Enable progress reporting
progressr::handlers("progress")

# Use in a loop
p <- create_progressor(10)
results <- lapply(1:10, function(i) {
  Sys.sleep(0.1)
  p()  # Signal progress
  i^2
})
} # }