with_progress_cnd | R Documentation |
with_progress
.Internal function. Use instead of
with_progress
within custom functions with progress
bars.
with_progress_cnd(ex, progress = TRUE)
ex |
expression |
progress |
logical, Default: TRUE |
This wrapper adds a progress parameter to with_progress
so that we can control the progress bar in the user facing functions. The progressbar
only shows in interactive mode.
No return value, called for side effects
with_progress
if (interactive()) {
with_progress_cnd(
purrr_bar(rep(0.25, 5), .purrr = purrr::map, .f = Sys.sleep, .steps = 5),
progress = TRUE
)
with_progress_cnd(
purrr_bar(rep(0.25, 5), .purrr = purrr::map, .f = Sys.sleep, .steps = 5),
progress = FALSE
)
# wrap a function with progress bar with another call with progress bar
f1 <- function(x, progress = TRUE) {
with_progress_cnd(
purrr_bar(x, .purrr = purrr::walk, .f = Sys.sleep, .steps = length(x), .progress = progress),
progress = progress
)
}
# inner progress bar blocks outer progress bar
progressr::with_progress(
purrr_bar(
rep(rep(1, 3),3), .purrr = purrr::walk, .f = f1, .steps = 3,
.f_args = list(progress = TRUE)
)
)
# inner progress bar turned off
progressr::with_progress(
purrr_bar(
rep(list(rep(0.25, 3)), 5), .purrr = purrr::walk, .f = f1, .steps = 5,
.f_args = list(progress = FALSE)
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.