| Title: | Print Loop Iterations at Exponentially Disparate Intervals |
|---|---|
| Description: | Know which loop iteration the code execution is up to by including a single, convenient function call inside the loop. |
| Authors: | Steve Condylios [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-0599-844X>), Zane Dax [ctb] |
| Maintainer: | Steve Condylios <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-19 06:47:43 UTC |
| Source: | https://github.com/stevecondylios/iterator |
Place inside a loop to automatically and conveniently print the current loop iteration at exponentially disparate (or custom) intervals.
iteration(iterator_name, iteration_values)iteration(iterator_name, iteration_values)
iterator_name |
The name of the loop iterator (e.g. "i") |
iteration_values |
An integer vector specifying loop iterations (defaults to the sequence 1, 2, 5, 10, 20, 50, 100, 200, 500 ....) |
iteration() is a non-value-returning function. As such, it will not return anything, and instead print to console the value representing the current loop iteration.
# For a loop that would otherwise give no feedback as to where it is up to, # simply include iteration() anywhere inside the loop to show progress for(i in 1:10000) { 2 * 2 iteration() } # 10 # 20 # 50 # 100 # 200 # 500 # 1,000 # 2,000 # 5,000 # 10,000 # 20,000 # 50,000 # To use an iterator other than 'i' (example: 'page') for(page in 1:10000) { 2 * 2 iteration("page") } # 10 # 20 # 50 # 100 # 200 # 500 # 1,000 # 2,000 # 5,000 # 10,000 # Use custom iteration intervals for(i in 1:10000) { 2 * 2 iteration(iteration_values = seq(0, 1e4, 1e3)) } # 1,000 # 2,000 # 3,000 # 4,000 # 5,000 # 6,000 # 7,000 # 8,000 # 9,000 # 10,000# For a loop that would otherwise give no feedback as to where it is up to, # simply include iteration() anywhere inside the loop to show progress for(i in 1:10000) { 2 * 2 iteration() } # 10 # 20 # 50 # 100 # 200 # 500 # 1,000 # 2,000 # 5,000 # 10,000 # 20,000 # 50,000 # To use an iterator other than 'i' (example: 'page') for(page in 1:10000) { 2 * 2 iteration("page") } # 10 # 20 # 50 # 100 # 200 # 500 # 1,000 # 2,000 # 5,000 # 10,000 # Use custom iteration intervals for(i in 1:10000) { 2 * 2 iteration(iteration_values = seq(0, 1e4, 1e3)) } # 1,000 # 2,000 # 3,000 # 4,000 # 5,000 # 6,000 # 7,000 # 8,000 # 9,000 # 10,000