Learn R Programming

fmcmc (version 0.5-2)

new_progress_bar: Progress bar

Description

A simple progress bar. This function is used in MCMC when the function has been called with a single processor.

Usage

new_progress_bar(
  n,
  probs = c(0, 0.25, 0.5, 0.75, 1),
  width = getOption("width", 80),
  symbol = "/",
  ...
)

Value

A function that can be included at the interior of a loop to mark the progress of the loop. It receives a single argument, i, which is the number of the current step.

Arguments

n

Integer. Number of steps.

probs

Double vector. Quantiles where to put marks

width

Integer. Width of the bar in characters.

symbol

Character. Single character symbol to print each bar.

...

Further arguments passed to cat() such as file and append.

Examples

Run this code

x <- new_progress_bar(20)
for (i in 1:20) {
  Sys.sleep(2/20)
  x(i)
}

Run the code above in your browser using DataLab