progress

Progress bar in your R terminal

https://github.com/r-lib/progress

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 15 committers (13.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.4%) to scientific vocabulary

Keywords

r

Keywords from Contributors

devtools setup reproducibility tidy-data package-creation survival-analysis unit-testing documentation-tool visualisation parallel-computing
Last synced: 10 months ago · JSON representation

Repository

Progress bar in your R terminal

Basic Info
Statistics
  • Stars: 475
  • Watchers: 8
  • Forks: 40
  • Open Issues: 8
  • Releases: 3
Topics
r
Created over 11 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Code of conduct

README.md



progress


R-CMD-check Codecov test coverage <!-- badges: end -->

Progress bar in your R terminal

An R package to show ASCII progress bars. Heavily influenced by the https://github.com/tj/node-progress JavaScript project.

Installation

Install the package from CRAN:

r install.packages("progress")

If you need the development version, install it from GitHub:

r pak::pak("r-lib/progress")

Usage

Use the progress_bar R6 class:

r library(progress) pb <- progress_bar$new(total = 100) for (i in 1:100) { pb$tick() Sys.sleep(1 / 100) }

[==========================================================-------------] 81%

The progress bar is displayed after the first tick command. This might not be desirable for long computations, because nothing is shown before the first tick. It is good practice to call tick(0) at the beginning of the computation or download, which shows the progress bar immediately.

r pb <- progress_bar$new(total = 100) f <- function() { pb$tick(0) Sys.sleep(3) for (i in 1:100) { pb$tick() Sys.sleep(1 / 100) } } f()

Custom format, with estimated time of completion:

r pb <- progress_bar$new( format = " downloading [:bar] :percent eta: :eta", total = 100, clear = FALSE, width= 60) for (i in 1:100) { pb$tick() Sys.sleep(1 / 100) }

downloading [========----------------------] 28% eta: 1s

With elapsed time:

r pb <- progress_bar$new( format = " downloading [:bar] :percent in :elapsed", total = 100, clear = FALSE, width= 60) for (i in 1:100) { pb$tick() Sys.sleep(1 / 100) }

downloading [==========================------] 80% in 1s

r pb <- progress_bar$new( format = " downloading [:bar] :elapsedfull", total = 1000, clear = FALSE, width= 60) for (i in 1:1000) { pb$tick() Sys.sleep(1 / 100) }

downloading [=====================--------------] 00:00:08

With number of number of ticks/total:

r total <- 1000 pb <- progress_bar$new(format = "[:bar] :current/:total (:percent)", total = total) f <- function() { pb$tick(0) Sys.sleep(3) for (i in 1:total) { pb$tick(1) Sys.sleep(1 / 100) } } f()

[============================-------------------------------------------------] 370/1000 ( 37%)

With custom tokens:

r pb <- progress_bar$new( format = " downloading :what [:bar] :percent eta: :eta", clear = FALSE, total = 200, width = 60) f <- function() { for (i in 1:100) { pb$tick(tokens = list(what = "foo ")) Sys.sleep(2 / 100) } for (i in 1:100) { pb$tick(tokens = list(what = "foobar")) Sys.sleep(2 / 100) } } f()

downloading foo [======------------------] 27% eta: 4s

It can show download rates for files with unknown sizes:

r pb <- progress_bar$new( format = " downloading foobar at :rate, got :bytes in :elapsed", clear = FALSE, total = 1e7, width = 60) f <- function() { for (i in 1:100) { pb$tick(sample(1:100 * 1000, 1)) Sys.sleep(2/100) } pb$tick(1e7) invisible() } f()

downloading foobar at 5.42 MB/s, got 15.45 MB in 3s

Progress bars can also digress, by supplying negative values to tick():

r pb <- progress_bar$new() f <- function() { pb$tick(50) ; Sys.sleep(1) pb$tick(-20) ; Sys.sleep(1) pb$tick(50) ; Sys.sleep(1) pb$tick(-30) ; Sys.sleep(1) pb$tick(100) } f()

See the manual for details and other options.

Usage with purrr iterators

If you prefer to do your iterative tasks using the purrr family of functional programming tools, rather than with for loops, there are two straightforward ways to add progress bars:

  1. Increment the ticks in-line when calling the purrr iterator.

  2. Define the task and increment the ticks in a separate wrapper function.

Option 1 is concise for simple one-line tasks (e.g. requiring only a single function call), while Option 2 is probably preferred for more complex multi-line tasks.

```r

Option 1

pb <- progress_bar$new(total = 100) purrr::walk(1:100, (...) { pb$tick(); Sys.sleep(0.1) }) [================================================>------] 89% ```

```r

Option 2

pb <- progress_bar$new(total = 100)

foo <- function(x){ pb$tick() Sys.sleep(0.1) }

purrr::walk(1:100, foo) [==================>------------------------------------] 34% ```

Creating a plyr compatible progress bar

It is easy to create progress bars for plyr:

r progress_progress <- function(...) { pb <- NULL list( init = function(x, ...) { pb <<- progress_bar$new(total = x, ...) }, step = function() { pb$tick() }, term = function() NULL ) }

You can try it with

r plyr::l_ply( 1:100, .fun = function(...) Sys.sleep(0.01), .progress = 'progress' )

C++ API

The package also provides a C++ API, that can be used with or without Rcpp. See the example package that is included within progress. Here is a short excerpt that shows how it works:

```CPP

include

...

RProgress::RProgress pb("Downloading [:bar] ETA: :eta");

pb.tick(0); for (int i = 0; i < 100; i++) { usleep(2.0 / 100 * 1000000); pb.tick(); }

...

```

The C++ API has almost the same functionality as the R API, except that it does not currently support custom tokens, custom streams, and callback functions.

Note that the C++ and the R APIs are independent and for a single progress bar you need to use either one exclusively.

License

MIT @ Gábor Csárdi, RStudio Inc

Owner

  • Name: R infrastructure
  • Login: r-lib
  • Kind: organization

GitHub Events

Total
  • Issues event: 3
  • Watch event: 8
  • Issue comment event: 9
  • Push event: 13
  • Pull request event: 7
  • Fork event: 1
  • Create event: 2
Last Year
  • Issues event: 3
  • Watch event: 8
  • Issue comment event: 9
  • Push event: 13
  • Pull request event: 7
  • Fork event: 1
  • Create event: 2

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 273
  • Total Committers: 15
  • Avg Commits per committer: 18.2
  • Development Distribution Score (DDS): 0.128
Past Year
  • Commits: 17
  • Committers: 2
  • Avg Commits per committer: 8.5
  • Development Distribution Score (DDS): 0.118
Top Committers
Name Email Commits
Gabor Csardi c****r@g****m 238
Jim Hester j****r@g****m 15
Michel m****g@g****m 3
Rich FitzJohn r****n@g****m 2
Matus Goljer m****r@g****m 2
Leon L****s@g****e 2
Tobias Fellinger e****5@s****t 2
Matthew T. Warkentin m****n@m****a 2
devillemereuil d****l 1
Matthew Henderson m****n@g****m 1
Henrik Bengtsson hb@a****g 1
Daniel Sjoberg d****g@g****m 1
Daniel Chen c****y 1
Dan Chaltiel d****l@g****m 1
Pierre de Villemereuil p****l@m****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 87
  • Total pull requests: 32
  • Average time to close issues: almost 2 years
  • Average time to close pull requests: over 1 year
  • Total issue authors: 52
  • Total pull request authors: 14
  • Average comments per issue: 2.3
  • Average comments per pull request: 1.59
  • Merged pull requests: 30
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 hour
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gaborcsardi (20)
  • jennybc (6)
  • HenrikBengtsson (4)
  • kevinushey (3)
  • richfitz (3)
  • jefferis (2)
  • hadley (2)
  • wlandau (2)
  • josswright (2)
  • khliland (1)
  • SangdonLim (1)
  • pati-ni (1)
  • moodymudskipper (1)
  • mattwarkentin (1)
  • MilesMcBain (1)
Pull Request Authors
  • jimhester (8)
  • gaborcsardi (8)
  • Fuco1 (3)
  • HenrikBengtsson (2)
  • meztez (2)
  • DanChaltiel (2)
  • ddsjoberg (2)
  • snaut (1)
  • chendaniely (1)
  • devillemereuil (1)
  • MHenderson (1)
  • mattwarkentin (1)
  • Lenostatos (1)
  • richfitz (1)
Top Labels
Issue Labels
upkeep (4) bug (3) feature (3) documentation (2)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 701,219 last-month
  • Total docker downloads: 46,725,509
  • Total dependent packages: 321
    (may contain duplicates)
  • Total dependent repositories: 678
    (may contain duplicates)
  • Total versions: 15
  • Total maintainers: 1
cran.r-project.org: progress

Terminal Progress Bars

  • Versions: 8
  • Dependent Packages: 281
  • Dependent Repositories: 631
  • Downloads: 701,219 Last month
  • Docker Downloads: 46,725,509
Rankings
Downloads: 0.3%
Dependent packages count: 0.4%
Dependent repos count: 0.5%
Stargazers count: 0.8%
Forks count: 1.9%
Average: 3.6%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 11 months ago
proxy.golang.org: github.com/r-lib/progress
  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 11 months ago
conda-forge.org: r-progress
  • Versions: 4
  • Dependent Packages: 40
  • Dependent Repositories: 47
Rankings
Dependent packages count: 1.7%
Dependent repos count: 5.2%
Average: 13.3%
Stargazers count: 18.6%
Forks count: 27.8%
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • R6 * imports
  • crayon * imports
  • hms * imports
  • prettyunits * imports
  • Rcpp * suggests
  • testthat * suggests
  • withr * suggests
tests/testthat/progresstest/DESCRIPTION cran
  • Rcpp * imports
  • progress * imports
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite