Learn R Programming

riemtan (version 0.2.5)

create_progressor: Create a Progress Reporter for Iterative Operations

Description

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)

Value

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

Arguments

steps

Integer specifying the total number of steps

enable

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

Details

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

See Also

progressr::progressor(), with_progress()

Examples

Run this code
if (FALSE) {
# 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
})
}

Run the code above in your browser using DataLab