Learn R Programming

prada (version 1.48.0)

progress: A simple tcltk progress window

Description

Show progress of a task in a tcltk window as percentage

Usage

progress(title="processing task...", message="", sub="") updateProgress(percentage, autoKill=FALSE, sub="") killProgress()

Arguments

title
The title of the tcltk window
message
A short test message to add to the window
sub
An additional text field that can be updated viaupdateProgress
percentage
An integer giving the percentage of completion
autoKill
Logical indicating whether to kill the display after 100 is reached

Value

Details

Function progress creates the progress window and sets up the necessary environment. updateProgress takes as argument an integer value indicating the percentage of completion and updates the display. The integer value that gets passed to updateProgress will usually be generated by an iterator (e.g. in a for loop). killProgress may be called explicitely to kill the progress window. Alternatively one can set the argument autoKill of updateProgress to TRUE to automatically kill the window once a value of 100 is reached.

Examples

Run this code
if(interactive() && capabilities()["tcltk"]){
  progress(message="This is a progress display...", sub="(step 1 of 50)")
  for(i in 1:50) {
     zz = rnorm(1e5)
     updateProgress(i*2, autoKill=TRUE, sub=paste("(step", i, "of 50)"))
  }
}

Run the code above in your browser using DataLab