Skip to contents

This function lets the user view a progressbar for a 'for' loop.

Usage

statusbar(
  run = 1,
  max.run = 100,
  label = run,
  msg = "",
  type = Sys.getenv("LARES_STATUSBAR"),
  start_time = NA,
  multiples = 1,
  alarm = FALSE
)

Arguments

run

Iterator. for loop or an integer with the current loop number. Start with 1 preferibly

max.run

Number. Maximum number of loops

label

String. With additionaly information to be printed at the end of the line. The default is run.

msg

Character. Finish message.

type

Character. Loading type style: equal, domino, sword, filled.

start_time

POSIXct. Start time to consider. If NA, then when first iteration starts will be set as start time. Useful for when first iteration is showed as done but started a few seconds/minutes ago.

multiples

Integer. Only print when multiples of N (to avoid) wasting resources on fast and lots of iterations.

alarm

Boolean. Ping (sound) when done. Requires beepr.

Value

No return value, called for side effects.

Examples

for (i in 1:9) {
  statusbar(i, 9, multiples = 2)
  Sys.sleep(0.3)
}
#> 
 00:00:00 [█████████                                ] 22.2% | 2                      
 00:00:01 [██████████████████                       ] 44.4% | 4                      
 00:00:02 [███████████████████████████              ] 66.7% | 6                      
 00:00:02 [████████████████████████████████████     ] 88.9% | 8                      
 00:00:02 [█████████████████████████████████████████] 100% | 9