| Title: | Wrap an Interable in a Progress Bar |
|---|---|
| Description: | Allows a simple creation of progress bars by wrapping the iterated object in 'pb()'. |
| Authors: | Laura Bakala [cre, aut, cph] (ORCID: <https://orcid.org/0000-0002-3213-2484>) |
| Maintainer: | Laura Bakala <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-05-26 08:10:02 UTC |
| Source: | https://github.com/turtletopia/aurrera |
Makes the object spawn a progress bar in response to indexing with [[
operator. Intended to be used with most iterators in R, e.g.:
base::lapply() and some of its cousins, base::Reduce(),
plyr::llply(), purrr::map(), foreach::foreach()...
pb(object, ...) ## Default S3 method: pb(object, ...) ## S3 method for class 'aurrera_iter' pb(object, ...)pb(object, ...) ## Default S3 method: pb(object, ...) ## S3 method for class 'aurrera_iter' pb(object, ...)
object |
|
... |
|
The original object with aurrera_iter class prepended that handles
progress bar display in response to indexing.
result <- lapply(pb(6:20), gmp::factorize) Reduce(`+`, pb(sample(1e5, 1e4))) # Progress bar won't display when iterating with `for` loop v <- character() for (letter in pb(letters[1:5])) { v <- c(letter, v) } v # On the other hand, manual indexing works properly x <- pb(letters[1:5]) for (i in seq_along(x)) { # Just be careful with printing inside a progress bar print(x[[i]]) }result <- lapply(pb(6:20), gmp::factorize) Reduce(`+`, pb(sample(1e5, 1e4))) # Progress bar won't display when iterating with `for` loop v <- character() for (letter in pb(letters[1:5])) { v <- c(letter, v) } v # On the other hand, manual indexing works properly x <- pb(letters[1:5]) for (i in seq_along(x)) { # Just be careful with printing inside a progress bar print(x[[i]]) }