/usr/lib/R/site-library/progress/README.metacran is in r-cran-progress 1.1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | <h1 align="center">
<br>
<br>
<img width="400" src="./inst/logo.png" alt="progress">
<br>
<br>
<br>
</h1>
[![Linux Build Status](https://travis-ci.org/gaborcsardi/progress.svg?branch=master)](https://travis-ci.org/gaborcsardi/progress)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/github/gaborcsardi/progress?svg=true)](https://ci.appveyor.com/project/gaborcsardi/progress)
[![](https://www.r-pkg.org/badges/version/progress)](https://r-pkg.org/pkg/progress)
> 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
```r
devtools::install_github("gaborcsardi/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
```
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.
## Creating a plyr compatible progress bar
It is easy to create progress bars for
[plyr](https://github.com/hadley/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](inst/progresstest/src/test.cpp) that
is [included](inst/progresstest) within `progress`. Here is a short excerpt
that shows how it works:
```CPP
#include <RProgress.h>
...
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
|