{"id":14069118,"url":"https://github.com/r-lib/progress","last_synced_at":"2025-05-14T02:08:24.143Z","repository":{"id":21453813,"uuid":"24772218","full_name":"r-lib/progress","owner":"r-lib","description":"Progress bar in your R terminal","archived":false,"fork":false,"pushed_at":"2025-04-28T11:10:52.000Z","size":5704,"stargazers_count":471,"open_issues_count":7,"forks_count":40,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-03T02:08:24.492Z","etag":null,"topics":["r"],"latest_commit_sha":null,"homepage":"http://r-lib.github.io/progress/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-03T20:14:56.000Z","updated_at":"2025-04-28T11:07:17.000Z","dependencies_parsed_at":"2024-11-12T06:02:47.136Z","dependency_job_id":null,"html_url":"https://github.com/r-lib/progress","commit_stats":{"total_commits":253,"total_committers":11,"mean_commits":23.0,"dds":"0.11857707509881421","last_synced_commit":"07fb16db0dbe4dd910e5c6947eeba7018d2c4a78"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fprogress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fprogress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fprogress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fprogress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/progress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043424,"owners_count":22004950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r"],"created_at":"2024-08-13T07:06:37.316Z","updated_at":"2025-05-14T02:08:19.128Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003cimg width=\"400\" src=\"man/figures/logo.png\" alt=\"progress\"\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-lib/progress/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/progress/actions/workflows/R-CMD-check.yaml)\n[![](https://www.r-pkg.org/badges/version/progress)](https://r-pkg.org/pkg/progress)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/progress/graph/badge.svg)](https://app.codecov.io/gh/r-lib/progress)\n\u003c!-- badges: end --\u003e\n\n\u003e Progress bar in your R terminal\n\nAn R package to show ASCII progress bars. Heavily influenced by\nthe https://github.com/tj/node-progress JavaScript project.\n\n## Installation\n\nInstall the package from CRAN:\n\n```r\ninstall.packages(\"progress\")\n```\n\nIf you need the development version, install it from GitHub:\n\n```r\npak::pak(\"r-lib/progress\")\n```\n\n## Usage\n\nUse the `progress_bar` R6 class:\n\n```r\nlibrary(progress)\npb \u003c- progress_bar$new(total = 100)\nfor (i in 1:100) {\n  pb$tick()\n  Sys.sleep(1 / 100)\n}\n```\n\n```\n[==========================================================-------------]  81%\n```\n\nThe progress bar is displayed after the first `tick` command.\nThis might not be desirable for long computations, because\nnothing is shown before the first tick. It is good practice to\ncall `tick(0)` at the beginning of the computation or download,\nwhich shows the progress bar immediately.\n\n```r\npb \u003c- progress_bar$new(total = 100)\nf \u003c- function() {\n  pb$tick(0)\n  Sys.sleep(3)\n  for (i in 1:100) {\n    pb$tick()\n    Sys.sleep(1 / 100)\n  }\n}\nf()\n```\n\nCustom format, with estimated time of completion:\n\n```r\npb \u003c- progress_bar$new(\n  format = \"  downloading [:bar] :percent eta: :eta\",\n  total = 100, clear = FALSE, width= 60)\nfor (i in 1:100) {\n  pb$tick()\n  Sys.sleep(1 / 100)\n}\n```\n\n```\n  downloading [========----------------------]  28% eta:  1s\n```\n\nWith elapsed time:\n\n```r\npb \u003c- progress_bar$new(\n  format = \"  downloading [:bar] :percent in :elapsed\",\n  total = 100, clear = FALSE, width= 60)\nfor (i in 1:100) {\n  pb$tick()\n  Sys.sleep(1 / 100)\n}\n```\n\n```\n  downloading [==========================------]  80% in  1s\n```\n\n```r\npb \u003c- progress_bar$new(\n  format = \"  downloading [:bar] :elapsedfull\",\n  total = 1000, clear = FALSE, width= 60)\nfor (i in 1:1000) {\n  pb$tick()\n  Sys.sleep(1 / 100)\n}\n```\n\n```\n  downloading [=====================--------------] 00:00:08\n```\n\nWith number of number of ticks/total:\n\n```r\ntotal \u003c- 1000\npb \u003c- progress_bar$new(format = \"[:bar] :current/:total (:percent)\", total = total)\nf \u003c- function() {\n  pb$tick(0)\n  Sys.sleep(3)\n  for (i in 1:total) {\n    pb$tick(1)\n    Sys.sleep(1 / 100)\n  }\n}\nf()\n```\n\n```\n[============================-------------------------------------------------] 370/1000 ( 37%)\n```\n\nWith custom tokens:\n\n```r\npb \u003c- progress_bar$new(\n  format = \"  downloading :what [:bar] :percent eta: :eta\",\n  clear = FALSE, total = 200, width = 60)\nf \u003c- function() {\n  for (i in 1:100) {\n    pb$tick(tokens = list(what = \"foo   \"))\n    Sys.sleep(2 / 100)\n  }\n  for (i in 1:100) {\n    pb$tick(tokens = list(what = \"foobar\"))\n    Sys.sleep(2 / 100)\n  }\n}\nf()\n```\n\n```\n  downloading foo    [======------------------]  27% eta:  4s\n```\n\nIt can show download rates for files with unknown sizes:\n\n```r\npb \u003c- progress_bar$new(\n  format = \"  downloading foobar at :rate, got :bytes in :elapsed\",\n  clear = FALSE, total = 1e7, width = 60)\nf \u003c- function() {\n  for (i in 1:100) {\n    pb$tick(sample(1:100 * 1000, 1))\n    Sys.sleep(2/100)\n  }\n  pb$tick(1e7)\n  invisible()\n}\nf()\n```\n\n```\n  downloading foobar at 5.42 MB/s, got 15.45 MB in  3s\n```\n\nProgress bars can also digress, by supplying negative values to `tick()`:\n\n```r\npb \u003c- progress_bar$new()\nf \u003c- function() {\n  pb$tick(50)  ; Sys.sleep(1)\n  pb$tick(-20) ; Sys.sleep(1)\n  pb$tick(50)  ; Sys.sleep(1)\n  pb$tick(-30) ; Sys.sleep(1)\n  pb$tick(100)\n}\nf()\n```\n\nSee the manual for details and other options.\n\n## Usage with `purrr` iterators\n\nIf 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:\n\n1. Increment the ticks *in-line* when calling the `purrr` iterator.\n\n2. Define the task and increment the ticks in a separate wrapper function.\n\n***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.\n\n```r\n# Option 1\npb \u003c- progress_bar$new(total = 100)\npurrr::walk(1:100, ~{pb$tick(); Sys.sleep(0.1)})\n```\n```\n[================================================\u003e------]  89%\n```\n\n```r\n# Option 2\npb \u003c- progress_bar$new(total = 100)\n\nfoo \u003c- function(x){\n  pb$tick()\n  Sys.sleep(0.1)\n}\n\npurrr::walk(1:100, foo)\n```\n```\n[==================\u003e------------------------------------]  34%\n```\n\n## Creating a plyr compatible progress bar\n\nIt is easy to create progress bars for\n[plyr](https://github.com/hadley/plyr):\n\n```r\nprogress_progress \u003c- function(...) {\n  pb \u003c- NULL\n  list(\n    init = function(x, ...) {\n      pb \u003c\u003c- progress_bar$new(total = x, ...)\n    },\n\tstep = function() {\n      pb$tick()\n    },\n\tterm = function() NULL\n  )\n}\n```\n\nYou can try it with\n\n```r\nplyr::l_ply(\n  1:100,\n  .fun = function(...) Sys.sleep(0.01),\n  .progress = 'progress'\n)\n```\n\n## C++ API\n\nThe package also provides a C++ API, that can be used with or\nwithout Rcpp. See [the example package](tests/testthat/progresstest/src/test.cpp) that\nis [included](tests/testthat/progresstest) within `progress`. Here is a short excerpt\nthat shows how it works:\n\n```CPP\n\n#include \u003cRProgress.h\u003e\n\n...\n\nRProgress::RProgress pb(\"Downloading [:bar] ETA: :eta\");\n\n  pb.tick(0);\n  for (int i = 0; i \u003c 100; i++) {\n    usleep(2.0 / 100 * 1000000);\n    pb.tick();\n  }\n\n...\n\n```\n\nThe C++ API has almost the same functionality as the R API, except that it\ndoes not currently support custom tokens, custom streams, and callback functions.\n\nNote that the C++ and the R APIs are independent and for a\nsingle progress bar you need to use either one exclusively.\n\n## License\n\nMIT @ [Gábor Csárdi](https://github.com/gaborcsardi),\n      [RStudio Inc](https://github.com/rstudio)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fprogress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fprogress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fprogress/lists"}