Learn R Programming

riemtan (version 0.2.5)

with_progress: Execute Expression with Progress Reporting

Description

Wrapper function that executes an expression with optional progress reporting. Integrates with the progressr package when available.

Usage

with_progress(expr, name = "Processing", enable = TRUE)

Value

The result of evaluating expr.

Arguments

expr

Expression to evaluate

name

Character string specifying the name of the operation (default: "Processing")

enable

Logical indicating whether to enable progress reporting (default: TRUE). If FALSE or if progressr is not available, the expression is executed without progress reporting.

Details

This function provides a consistent interface for progress reporting across riemtan. Progress handlers can be configured using progressr::handlers().

When enable = TRUE and progressr is installed, users can see progress by calling:

progressr::handlers("progress")  # or "txtprogressbar", "cli", etc.

See Also

Examples

Run this code
if (FALSE) {
# Enable progress reporting
progressr::handlers("progress")

# Use within a function
result <- with_progress({
  p <- progressr::progressor(steps = 10)
  lapply(1:10, function(i) {
    Sys.sleep(0.1)
    p()  # Signal progress
    i^2
  })
}, name = "Computing squares")
}

Run the code above in your browser using DataLab