Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Progress bar variables

Source:R/progress-variables.R
progress-variables.Rd

Progress bar variables

Details

These variables can be used in cli progress bar formatstrings. They are calculated on demand. To use a variable, e.g.pb_barin a package, you either need to to importpb_bar from cli, or usethe qualified form in the format string:cli::pb_bar.

Similarly, in R scripts, you can usepb_bar afterlibrary(cli),orcli::pb_bar if you do not attach the cli package.

pb_bar

Creates a visual progress bar. If the number of total unitsis unknown, then it will return an empty string.

cli_progress_bar(  total=100,  format="Fitting model {cli::pb_bar} {cli::pb_percent}")

#> Fitting model███████████████████████████████  66%

pb_current

The number of current progress units.

cli_progress_bar(  total=100,  format="{cli::pb_spin} Reading file {cli::pb_current}/{cli::pb_total}")

#> ⠙ Reading file 66/100

pb_current_bytes

The number of current progress units formatted as bytes.The output has a constant width of six characters.

cli_progress_bar(  format="Got {cli::pb_current_bytes} in {cli::pb_elapsed}")

#> Got 524 kB in 5s

pb_elapsed

The elapsed time since the start of the progress bar. The time ismeasured since the progress bar was created withcli_progress_bar()or similar.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} [{cli::pb_elapsed}]")

#>███████████████████████████████  66% [5s]

pb_elapsed_clock

The elapsed time, inhh::mm::ss format.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} [{cli::pb_elapsed_clock}]")

#>███████████████████████████████  66% [00:00:05]

pb_elapsed_raw

The number of seconds since the start of the progress bar.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} [{round(cli::pb_elapsed_raw)}s]")

#>███████████████████████████████  66% [5s]

pb_eta

The estimated time until the end of the progress bar,in human readable form.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} | ETA: {cli::pb_eta}")

#>███████████████████████████████  66% | ETA:  3s

pb_eta_raw

The estimated time until the end of the progressbar, in seconds. This is useful if you want to adjust the defaultpb_eta display.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} | ETA: {round(cli::pb_eta_raw)}s")

#>███████████████████████████████  66% | ETA: 3s

pb_eta_str

The estimated time until the end of the progress bar.It includes the"ETA:" prefix. It is only shown if the time can beestimated, otherwise it is the empty string.

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent} | {cli::pb_eta_str}")

#>███████████████████████████████  66% | ETA:  3s

pb_extra

pb_extra can be used to access extra data, see theextra argumentofcli_progress_bar() andcli_progress_update().

cli_progress_bar(  total=100,  extra=list(user=whoami::username()),  format="Cleaning cache for user '{cli::pb_extra$user}': {cli::pb_current_bytes}")

#> Cleaning cache for user 'gaborcsardi': 161 MB

pb_id

The id of the progress bar. The id has the formatcli-<pid>-<counter> where<pid> is the process id, and<counter> is an integer counter that is incremented every timecli needs a new unique id.

This is useful for debugging progress bars.

cli_progress_bar(  format="Progress bar '{cli::pb_id}' is at {cli::pb_current}")

#> Progress bar 'cli-40403-1860' is at 64

pb_name

The name of the progress bar. This is supplied by thedeveloper, and it is by default the empty string. A space characteris added to non-empty names.

cli_progress_bar(  name="Loading training data",  total=100,  format="{cli::pb_name} {cli::pb_bar} {cli::pb_percent}")

#> Loading training data███████████████████████████████  66%

pb_percent

The percentage of the progress bar, always formattedin three characters plus the percentage sign. If the total number ofunits is unknown, then it is" NA%".

cli_progress_bar(  total=100,  format="{cli::pb_bar} {cli::pb_percent}")

#>███████████████████████████████  66%

pb_pid

The integer process id of the progress bar. This is useful if you areaggregating logging output or progress results from multiple processes.

pb_rate

The progress rate, in number of units per second, formatted in a string.

cli_progress_bar(  total=156,  format="Reading input files {pb_current}/{pb_total} [{pb_rate}]")

#> Reading input files 68/156 [14/s]

pb_rate_raw

The raw progress rate, in number of units per second.

cli_progress_bar(  total=156,  format="Reading input files {pb_current}/{pb_total} [{round(pb_rate_raw)}/s]")

#> Reading input files 68/156 [14/s]

pb_rate_bytes

The progress rate, formatted as bytes per second, in human readable form.

cli_progress_bar(  total = 256 * 1024 * 1014,  format = paste0(    "Reading data {pb_current_bytes}/{pb_total_bytes} ",    "[{ansi_trimws(pb_rate_bytes)}]"  )

#> Reading data  70 MB/266 MB [14 MB/s]

pb_spin

A spinner. The default spinner is selected via aget_spinner() call.

cli_progress_bar(  total=100,  format="{cli::pb_spin} Reading file {cli::pb_current}/{cli::pb_total}")

#> ⠙ Reading file 66/100

pb_status

The status string of the progress bar. By default this is an emptystring, but it is possible to set it incli_progress_bar()and `cli_progress_update()].

cli_progress_bar(status="Connecting...")

#> ⠙ Connecting... 0 done (0/s) | 1s

pb_timestamp

A time stamp for the current time in ISO 8601 format.

cli_progress_bar(  "Loading training data files",  format = "{pb_timestamp} {pb_current} ({pb_rate})"

#> 2025-04-22T12:27:16+00:00 125 (25/s)

pb_total

The total number of progress units, orNA if the number of units isunknown.

cli_progress_bar(  total=100,  format="{cli::pb_spin} Reading file {cli::pb_current}/{cli::pb_total}")

#> ⠙ Reading file 66/100

pb_total_bytes

The total number of progress units, formatted asbytes, in a human readable format.

cli_progress_bar(  total = 256 * 1024 * 1014,  format = paste0(    "Reading data {pb_current_bytes}/{pb_total_bytes} ",    "[{ansi_trimws(pb_rate_bytes)}]"  )

#> Reading data  70 MB/266 MB [14 MB/s]

See also

Other progress bar functions:cli_progress_along(),cli_progress_bar(),cli_progress_builtin_handlers(),cli_progress_message(),cli_progress_num(),cli_progress_output(),cli_progress_step(),cli_progress_styles()


[8]ページ先頭

©2009-2025 Movatter.jp