print_loop_progress: print loop progress

Description Usage Arguments Examples

View source: R/print_loop_progress.R

Description

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

Usage

1
2
3
4
5
6
7
8
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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 April 25, 2021, 1:06 a.m.