View source: R/progress_utils.R
| with_progress | R Documentation |
Wrapper function that executes an expression with optional progress reporting. Integrates with the progressr package when available.
with_progress(expr, name = "Processing", enable = TRUE)
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. |
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.
The result of evaluating expr.
progressr::with_progress(), progressr::progressor()
## Not run:
# 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")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.