print_loop_progress: print loop progress

View source: R/print_loop_progress.R

print_loop_progressR Documentation

print loop progress

Description

Print current progress inside a loop (e.g., for loop or lapply)

Usage

print_loop_progress(
  iteration_number = NULL,
  iteration_start = 1,
  iteration_end = NULL,
  text_before = "",
  percent = 1,
  output_method = "cat"
)

Arguments

iteration_number

current number of iteration

iteration_start

iteration number at which the loop begins (default = 1)

iteration_end

iteration number at which the loop ends.

text_before

text to add before "Loop Progress..." By default, it is set to be blank, i.e., text_before = ""

percent

if percent = 1, progress level will be printed at every 1 percent progress (default = 1)

output_method

if output_method = "cat", progress level will be printed using the 'cat' function; if output_method = "return", progress level will be returned as the output of the function (default = "cat")

Examples

for (i in seq_len(250)) {
  Sys.sleep(0.001)
  print_loop_progress(
    iteration_number = i,
    iteration_end = 250)
}
unlist(lapply(seq_len(7), function (i) {
  Sys.sleep(0.1)
  print_loop_progress(
    iteration_number = i,
    iteration_end = 7)
  return(i)
}))

kim documentation built on Oct. 9, 2023, 5:08 p.m.