Learn R Programming

R.utils (version 2.12.2)

ProgressBar: Provides text based counting progress bar

Description

Package: R.utils
Class ProgressBar

Object
~~|
~~+--ProgressBar

Directly known subclasses:
FileProgressBar

public static class ProgressBar
extends Object

Usage

ProgressBar(max=100, ticks=10, stepLength=1, newlineWhenDone=TRUE)

Arguments

max

The maximum number of steps.

ticks

Put visual "ticks" every ticks step.

stepLength

The default length for each increase.

newlineWhenDone

If TRUE, a newline is outputted when bar is updated, when done, otherwise not.

Fields and Methods

Methods:

as.characterGets a string description of the progress bar.
getBarStringGets the progress bar string to be displayed.
increaseIncreases (steps) progress bar.
isDoneChecks if progress bar is completed.
resetReset progress bar.
setMaxValueSets maximum value.
setProgressSets current progress.
setStepLengthSets default step length.
setTicksSets values for which ticks should be visible.
setValueSets current value.
updateUpdates progress bar.

Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save

Author

Henrik Bengtsson

Examples

Run this code
# A progress bar with default step length one.
pb <- ProgressBar(max=42)
reset(pb)
while (!isDone(pb)) {
  x <- rnorm(3e4)
  increase(pb)
  # Emulate a slow process
  if (interactive()) Sys.sleep(0.02)
}
cat("\n")

# A "faster" progress bar with default step length 1.4.
pb <- ProgressBar(max=42, stepLength=1.4)
reset(pb)
while (!isDone(pb)) {
  x <- rnorm(3e4)
  increase(pb)
  # Emulate a slow process
  if (interactive()) Sys.sleep(0.02)
}

cat("\n")

Run the code above in your browser using DataLab