pbtick: Update progress if the progress bar is not 'NULL'.

View source: R/utils.R

pbtickR Documentation

Update progress if the progress bar is not NULL.

Description

This allows for flexible code that only initializes a progress bar if the progressr package is installed.

Usage

pbtick(pb, message = NULL)

Arguments

pb

a progress bar created with progressr.

message

optional message to report (default: NULL).

Author(s)

Kelly Sovacool sovacool@umich.edu

Examples

## Not run: 
f <- function() {
  if (isTRUE(check_packages_installed("progressr"))) {
    pb <- progressr::progressor(steps = 5, message = "looping")
  } else {
    pb <- NULL
  }
  for (i in 1:5) {
    pbtick(pb)
    Sys.sleep(0.5)
  }
}
progressr::with_progress(
  f()
)

## End(Not run)

SchlossLab/mikropml documentation built on Aug. 24, 2023, 9:51 p.m.