spatstat (version 1.45-0)

progressreport: Print Progress Reports

Description

Prints Progress Reports during a loop or iterative calculation.

Usage

progressreport(i, n,
               every = min(100,max(1, ceiling(n/100))),
               nperline = min(charsperline,
                              every * ceiling(charsperline/(every + 3))),
               charsperline = 60,
               style=spatstat.options("progress"),
               state=NULL)

Arguments

i
Integer. The current iteration number (from 1 to n).
n
Integer. The (maximum) number of iterations to be computed.
every
Optional integer. The number of iterations between successive reports.
nperline
Optional integer. The maximum number of reports to be printed per line of output.
charsperline
Optional integer. The number of characters in a line of output.
style
Character string determining the style of display. See Details.
state
Optional. A list containing the internal data.

Value

  • If state was NULL, the result is NULL. Otherwise the result is the updated value of state.

Details

This is a convenient function for reporting progress during an iterative sequence of calculations or a suite of simulations.

If style="tk" then tcltk::tkProgressBar is used to pop-up a new graphics window showing a progress bar. This requires the package tcltk.

If style="txtbar" then txtProgressBar is used to represent progress as a bar made of text characters in the Rinterpreter window.

If style="tty", then progress reports are printed using cat. This only seems to work well under Linux.

It is optional, but strongly advisable, to use the argument state to store and update the internal data for the progress reports (such as the cumulative time taken for computation) as shown in the last example below. This avoids conflicts with other programs that might be calling progressreport at the same time.

Examples

Run this code
for(i in 1:40) {
     #
     # code that does something...
     # 
     progressreport(i, 40)
  }

  # saving internal state
  sta <- list()
  for(i in 1:20) {
     # some code ...
     sta <- progressreport(i, 20, state=sta)
  }

Run the code above in your browser using DataLab