progressr/ 0000755 0001762 0000144 00000000000 14465264632 012314 5 ustar ligges users progressr/NAMESPACE 0000644 0001762 0000144 00000002105 14372060073 013517 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(conditionMessage,progression)
S3method(print,progression)
S3method(print,progression_handler)
S3method(print,progressor)
export(handler_ascii_alert)
export(handler_beepr)
export(handler_cli)
export(handler_debug)
export(handler_filesize)
export(handler_newline)
export(handler_notifier)
export(handler_pbcol)
export(handler_pbmcapply)
export(handler_progress)
export(handler_rpushbullet)
export(handler_rstudio)
export(handler_shiny)
export(handler_tkprogressbar)
export(handler_txtprogressbar)
export(handler_void)
export(handler_winprogressbar)
export(handlers)
export(make_progression_handler)
export(progress)
export(progress_aggregator)
export(progress_progressr)
export(progression)
export(progressor)
export(slow_sum)
export(withProgressShiny)
export(with_progress)
export(without_progress)
importFrom(digest,digest)
importFrom(utils,capture.output)
importFrom(utils,file_test)
importFrom(utils,flush.console)
importFrom(utils,object.size)
importFrom(utils,setTxtProgressBar)
importFrom(utils,str)
importFrom(utils,txtProgressBar)
progressr/demo/ 0000755 0001762 0000144 00000000000 14422114504 013221 5 ustar ligges users progressr/demo/mandelbrot.R 0000644 0001762 0000144 00000005142 14422114504 015475 0 ustar ligges users library(progressr)
library(future)
library(graphics)
p <- function(...) NULL
plot_what_is_done <- function(counts) {
done <- 0L
for (kk in seq_along(counts)) {
f <- counts[[kk]]
## Already plotted?
if (!inherits(f, "Future")) {
done <- done + 1L
next
}
## Not resolved?
## NOTE: This will block, if all workers are busy!
if (runif(1) < 0.8*(1-(done/length(counts))) || !resolved(f)) next
message(sprintf("Plotting tile #%d of %d ...", kk, n))
counts[[kk]] <- value(f)
screen(kk)
plot(counts[[kk]])
done <- done + 1L
}
counts
}
## Options
region <- getOption("future.demo.mandelbrot.region", 1L)
if (!is.list(region)) {
if (region == 1L) {
region <- list(xmid = -0.75, ymid = 0.0, side = 3.0)
} else if (region == 2L) {
region <- list(xmid = 0.283, ymid = -0.0095, side = 0.00026)
} else if (region == 3L) {
region <- list(xmid = 0.282989, ymid = -0.01, side = 3e-8)
}
}
nrow <- getOption("future.demo.mandelbrot.nrow", 5L)
resolution <- getOption("future.demo.mandelbrot.resolution", 1024L)
delay <- getOption("future.demo.mandelbrot.delay", interactive())
if (isTRUE(delay)) {
delay <- function(counts) Sys.sleep(runif(1L, min=0.5, max=5))
} else if (!is.function(delay)) {
delay <- function(counts) {}
}
## Generate Mandelbrot tiles to be computed
Cs <- mandelbrot_tiles(xmid = region$xmid, ymid = region$ymid,
side = region$side, nrow = nrow,
resolution = resolution)
message("Tiles: ", paste(dim(Cs), collapse = " by "))
if (interactive()) {
dev.new()
plot.new()
split.screen(dim(Cs))
for (ii in seq_along(Cs)) {
screen(ii)
par(mar = c(0, 0, 0, 0))
text(x = 1 / 2, y = 1 / 2, sprintf("Future #%d\nunresolved", ii), cex = 2)
}
} else {
split.screen(dim(Cs))
}
## Create all Mandelbrot tiles via lazy futures
n <- length(Cs)
message(sprintf("* Creating %d Mandelbrot tiles", n))
with_progress({
p <- progressor(along = Cs)
counts <- lapply(seq_along(Cs), FUN=function(ii) {
C <- Cs[[ii]]
future({
message(sprintf("Calculating tile #%d of %d ...", ii, n), appendLF = FALSE)
fit <- mandelbrot(C)
## Emulate slowness
delay(fit)
p(sprintf("Tile #%d (PID %d)", ii, Sys.getpid()))
message(" done")
fit
}, lazy = TRUE)
})
str(counts)
pp <- 0L
while (any(sapply(counts, FUN = inherits, "Future"))) {
counts <- plot_what_is_done(counts)
}
})
close.screen()
message("SUGGESTION: Try to rerun this demo after changing strategy for how futures are resolved, e.g. plan(multisession).\n")
progressr/demo/00Index 0000644 0001762 0000144 00000000113 14372060073 014353 0 ustar ligges users mandelbrot Produce Mandelbrot Set Images in Parallel with Progress Updates
progressr/man/ 0000755 0001762 0000144 00000000000 14465157214 013064 5 ustar ligges users progressr/man/handlers.Rd 0000644 0001762 0000144 00000007574 14372060073 015161 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handlers.R
\name{handlers}
\alias{handlers}
\title{Control How Progress is Reported}
\usage{
handlers(
...,
append = FALSE,
on_missing = c("error", "warning", "ignore"),
default = handler_txtprogressbar,
global = NULL
)
}
\arguments{
\item{\dots}{One or more progression handlers. Alternatively, this
functions accepts also a single vector of progression handlers as input.
If this vector is empty, then an empty set of progression handlers will
be set.}
\item{append}{(logical) If FALSE, the specified progression handlers
replace the current ones, otherwise appended to them.}
\item{on_missing}{(character) If \code{"error"}, an error is thrown if one of
the progression handlers does not exists. If \code{"warning"}, a warning
is produces and the missing handlers is ignored. If \code{"ignore"}, the
missing handlers is ignored.}
\item{default}{The default progression calling handler to use if none
are set.}
\item{global}{If TRUE, then the global progression handler is enabled.
If FALSE, it is disabled. If NA, then TRUE is returned if it is enabled,
otherwise FALSE. Argument \code{global} must not used with other arguments.}
}
\value{
(invisibly) the previous list of progression handlers set.
If no arguments are specified, then the current set of progression
handlers is returned.
If \code{global} is specified, then TRUE is returned if the global progression
handlers is enabled, otherwise false.
}
\description{
Control How Progress is Reported
}
\details{
This function provides a convenient alternative for getting and setting
option \option{progressr.handlers}.
}
\section{For package developers}{
\strong{IMPORTANT: Setting progression handlers is a privilege that should be
left to the end user. It should not be used by R packages, which only task
is to \emph{signal} progress updates, not to decide if, when, and how progress
should be reported.}
If you have to set or modify the progression handlers inside a function,
please make sure to undo the settings afterward. If not, you will break
whatever progression settings the user already has for other purposes
used elsewhere. To undo you settings, you can do:
\if{html}{\out{
}}
}
\section{Configuring progression handling during R startup}{
A convenient place to configure the default progression handler and to
enable global progression reporting by default is in the \file{~/.Rprofile}
startup file. For example, the following will (i) cause your interactive
R session to use global progression handler by default, and (ii) report
progress via the \pkg{progress} package when in the terminal and via the
RStudio Jobs progress bar when in the RStudio Console.
\link{handler_txtprogressbar},
other whenever using the RStudio Console, add
the following to your \file{~/.Rprofile} startup file:
\if{html}{\out{
}}\preformatted{if (interactive() && requireNamespace("progressr", quietly = TRUE)) \{
## Enable global progression updates
if (getRversion() >= 4) progressr::handlers(global = TRUE)
## In RStudio Console, or not?
if (Sys.getenv("RSTUDIO") == "1" && !nzchar(Sys.getenv("RSTUDIO_TERM"))) \{
options(progressr.handlers = progressr::handler_rstudio)
\} else \{
options(progressr.handlers = progressr::handler_progress)
\}
\}
}\if{html}{\out{
}}
}
\examples{
handlers("txtprogressbar")
if (requireNamespace("beepr", quietly = TRUE))
handlers("beepr", append = TRUE)
with_progress({ y <- slow_sum(1:5) })
print(y)
if (getRversion() >= "4.0.0") {
\dontshow{if (!is.element("pkgdown", loadedNamespaces()))}
handlers(global = TRUE)
y <- slow_sum(1:4)
z <- slow_sum(6:9)
\dontshow{if (!is.element("pkgdown", loadedNamespaces()))}
handlers(global = FALSE)
}
}
progressr/man/handler_pbcol.Rd 0000644 0001762 0000144 00000004760 14422114703 016143 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_pbcol.R
\name{handler_pbcol}
\alias{handler_pbcol}
\title{Progression Handler: Progress Reported as an ANSI Background Color in the Terminal}
\usage{
handler_pbcol(
adjust = 0,
pad = 1L,
complete = function(s) cli::bg_blue(cli::col_white(s)),
incomplete = function(s) cli::bg_cyan(cli::col_white(s)),
intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
target = "terminal",
...
)
}
\arguments{
\item{adjust}{(numeric) The adjustment of the progress update,
where \code{adjust = 0} positions the message to the very left, and
\code{adjust = 1} positions the message to the very right.}
\item{pad}{(integer) Amount of padding on each side of the message,
where padding is done by spaces.}
\item{complete, incomplete}{(function) Functions that take "complete" and
"incomplete" strings that comprise the progress bar as input and annotate
them to reflect their two different parts. The default is to annotation
them with two different background colors and the same foreground color
using the \pkg{cli} package.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
Progression Handler: Progress Reported as an ANSI Background Color in the Terminal
}
\section{Requirements}{
This progression handler requires the \pkg{cli} package.
}
\section{Appearance}{
Below are a few examples on how to use and customize this progress handler.
In all cases, we use \code{handlers(global = TRUE)}.
\if{html}{\out{
}}\preformatted{handlers("pbcol")
y <- slow_sum(1:25)
}\if{html}{\out{
}}
\if{html}{\figure{handler_pbcol-adjust-right-complete.svg}}
}
\examples{
handlers(handler_pbcol)
with_progress({ y <- slow_sum(1:10) })
print(y)
}
progressr/man/handler_newline.Rd 0000644 0001762 0000144 00000002075 14372060073 016506 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_newline.R
\name{handler_newline}
\alias{handler_newline}
\title{Progression Handler: Progress Reported as a New Line (Text) in the Terminal}
\usage{
handler_newline(
symbol = "\\n",
file = stderr(),
intrusiveness = getOption("progressr.intrusiveness.debug", 0),
target = "terminal",
...
)
}
\arguments{
\item{symbol}{(character string) The character symbol to be outputted,
which by default is the ASCII NL character (\code{'\\n'} = \code{'\\013'}) character.}
\item{file}{(connection) A \link[base:connections]{base::connection} to where output should be sent.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
Progression Handler: Progress Reported as a New Line (Text) in the Terminal
}
\keyword{internal}
progressr/man/progressor.Rd 0000644 0001762 0000144 00000006103 14372060073 015551 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progressor.R
\name{progressor}
\alias{progressor}
\title{Create a Progressor Function that Signals Progress Updates}
\usage{
progressor(
steps = length(along),
along = NULL,
offset = 0L,
scale = 1L,
transform = function(steps) scale * steps + offset,
message = character(0L),
label = NA_character_,
trace = FALSE,
initiate = TRUE,
auto_finish = TRUE,
on_exit = !identical(envir, globalenv()),
enable = getOption("progressr.enable", TRUE),
envir = parent.frame()
)
}
\arguments{
\item{steps}{(integer) Number of progressing steps.}
\item{along}{(vector; alternative) Alternative that sets
\code{steps = length(along)}.}
\item{offset, scale}{(integer; optional) scale and offset applying transform
\code{steps <- scale * steps + offset}.}
\item{transform}{(function; optional) A function that takes the effective
number of \code{steps} as input and returns another finite and non-negative
number of steps.}
\item{message}{(character vector or a function) If a character vector, then
it is pasted together into a single string using an empty separator.
If a function, then the message is constructed by \code{conditionMessage(p)}
calling this function with the progression condition \code{p} itself as the
first argument.}
\item{label}{(character) A label.}
\item{trace}{(logical) If TRUE, then the call stack is recorded, otherwise
not.}
\item{initiate}{(logical) If TRUE, the progressor will signal a
\link{progression} 'initiate' condition when created.}
\item{auto_finish}{(logical) If TRUE, then the progressor will signal a
\link{progression} 'finish' condition as soon as the last step has been reached.}
\item{on_exit, envir}{(logical) If TRUE, then the created progressor will
signal a \link{progression} 'finish' condition when the calling frame exits.
This is ignored if the calling frame (\code{envir}) is the global environment.}
\item{enable}{(logical) If TRUE, \link{progression} conditions are signaled when
calling the progressor function created by this function.
If FALSE, no \link{progression} conditions is signaled because the progressor
function is an empty function that does nothing.}
}
\value{
A function of class \code{progressor}.
}
\description{
Create a Progressor Function that Signals Progress Updates
}
\details{
A \code{progressor} function can only be created inside a local environment,
e.g. inside a function, within a \code{local()} call, or within a
\code{with_progress()} call. Notably, it \emph{cannot} be create at the top level,
e.g. immediately at the R prompt or outside a local environment in an
R script. If attempted, an informative error message is produced, e.g.
\if{html}{\out{
}}\preformatted{> p <- progressr::progressor(100)
Error in progressr::progressor(100) :
A progressor must not be created in the global environment unless
wrapped in a with_progress() or without_progress() call. Alternatively,
create it inside a function or in a local() environment to make sure
there is a finite life span of the progressor
}\if{html}{\out{
}}
}
progressr/man/handler_tkprogressbar.Rd 0000644 0001762 0000144 00000003236 14372060073 017735 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_tkprogressbar.R
\name{handler_tkprogressbar}
\alias{handler_tkprogressbar}
\title{Progression Handler: Progress Reported as a Tcl/Tk Progress Bars in the GUI}
\usage{
handler_tkprogressbar(
intrusiveness = getOption("progressr.intrusiveness.gui", 1),
target = "terminal",
inputs = list(title = NULL, label = "message"),
...
)
}
\arguments{
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{inputs}{(named list) Specifies from what sources the MS Windows
progress elements 'title' and 'label' should be updated. Valid sources are
\code{"message"}, \code{"sticky_message"} and \code{"non_sticky_message"}, where
\code{"message"} is short for \code{c("non_sticky_message", "sticky_message")}. For
example, \code{inputs = list(title = "sticky_message", label = "message")}
will update the 'title' component from sticky messages only,
whereas the 'label' component is updated using any message.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{\link[tcltk:tkProgressBar]{tcltk::tkProgressBar()}}.
}
\section{Requirements}{
This progression handler requires the \pkg{tcltk} package and that the
current R session supports Tcl/Tk (\code{capabilities("tcltk")}).
}
\examples{
if (capabilities("tcltk") && requireNamespace("tcltk", quietly = TRUE)) {
handlers("tkprogressbar")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
progressr/man/handler_notifier.Rd 0000644 0001762 0000144 00000002305 14372060073 016660 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_notifier.R
\name{handler_notifier}
\alias{handler_notifier}
\title{Progression Handler: Progress Reported via the Operating-System Notification Framework (GUI, Text)}
\usage{
handler_notifier(
intrusiveness = getOption("progressr.intrusiveness.notifier", 10),
target = "gui",
...
)
}
\arguments{
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{notify()} of the \pkg{notifier} package.
}
\section{Requirements}{
This progression handler requires the \pkg{notifier} package, which is only
available from \url{https://github.com/gaborcsardi/notifier}. This can be
installed as \code{remotes::install_github("gaborcsardi/notifier@62d484")}.
}
\examples{
pkg <- "notifier"
if (requireNamespace(pkg, quietly = TRUE)) {
handlers("notifier")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
\keyword{internal}
progressr/man/handler_rstudio.Rd 0000644 0001762 0000144 00000003322 14372060073 016532 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_rstudio.R
\name{handler_rstudio}
\alias{handler_rstudio}
\title{Progression Handler: Progress Reported in the RStudio Console}
\usage{
handler_rstudio(
intrusiveness = getOption("progressr.intrusiveness.gui", 1),
target = "gui",
title = function() format(Sys.time(), "Console \%X"),
...
)
}
\arguments{
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{title}{(character or a function) The "name" of the progressor, which
is displayed in front of the progress bar. If a function, then the name
is created dynamically by calling the function when the progressor is
created.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
Progression Handler: Progress Reported in the RStudio Console
}
\section{Requirements}{
This progression handler works only in the RStudio Console.
}
\section{Use this progression handler by default}{
To use this handler by default whenever using the RStudio Console, add
the following to your \file{~/.Rprofile} startup file:
\if{html}{\out{
}}
}
\examples{
if (requireNamespace("rstudioapi", quietly = TRUE) && rstudioapi::isAvailable()) {
handlers("rstudio")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
progressr/man/handler_beepr.Rd 0000644 0001762 0000144 00000002345 14372060073 016142 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_beepr.R
\name{handler_beepr}
\alias{handler_beepr}
\title{Progression Handler: Progress Reported as 'beepr' Sounds (Audio)}
\usage{
handler_beepr(
initiate = 2L,
update = 10L,
finish = 11L,
interrupt = 9L,
intrusiveness = getOption("progressr.intrusiveness.audio", 5),
target = "audio",
...
)
}
\arguments{
\item{initiate, update, finish, interrupt}{(integer) Indices of \code{\link[beepr:beep]{beepr::beep()}}
sounds to play when progress starts, is updated, completes, or is
interrupted. For silence, use \code{NA_integer_}.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{\link[beepr:beep]{beepr::beep()}}.
}
\section{Requirements}{
This progression handler requires the \pkg{beepr} package.
}
\examples{
if (requireNamespace("beepr", quietly = TRUE)) {
handlers("beepr")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
progressr/man/handler_debug.Rd 0000644 0001762 0000144 00000003546 14372060073 016137 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_debug.R
\name{handler_debug}
\alias{handler_debug}
\title{Progression Handler: Progress Reported as Debug Information (Text) in the Terminal}
\usage{
handler_debug(
interval = getOption("progressr.interval", 0),
intrusiveness = getOption("progressr.intrusiveness.debug", 0),
target = "terminal",
uuid = FALSE,
...
)
}
\arguments{
\item{interval}{(numeric) The minimum time (in seconds) between
successive progression updates from this handler.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{uuid}{If TRUE, then the progressor UUID and the owner UUID are shown,
otherwise not (default).}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
Progression Handler: Progress Reported as Debug Information (Text) in the Terminal
}
\section{Appearance}{
Below is how this progress handler renders by default at 0\%, 30\% and 99\%
progress:
With \code{handlers(handler_debug())}:
\if{html}{\out{
}}
}
\examples{
handlers("debug")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
progressr/man/with_progress.Rd 0000644 0001762 0000144 00000011403 14433726175 016254 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/with_progress.R, R/without_progress.R
\name{with_progress}
\alias{with_progress}
\alias{without_progress}
\title{Report on Progress while Evaluating an R Expression}
\usage{
with_progress(
expr,
handlers = progressr::handlers(),
cleanup = TRUE,
delay_terminal = NULL,
delay_stdout = NULL,
delay_conditions = NULL,
interrupts = getOption("progressr.interrupts", TRUE),
interval = NULL,
enable = NULL
)
without_progress(expr)
}
\arguments{
\item{expr}{An \R expression to evaluate.}
\item{handlers}{A progression handler or a list of them.
If NULL or an empty list, progress updates are ignored.}
\item{cleanup}{If TRUE, all progression handlers will be shutdown
at the end regardless of the progression is complete or not.}
\item{delay_terminal}{If TRUE, output and conditions that may end up in
the terminal will delayed.}
\item{delay_stdout}{If TRUE, standard output is captured and relayed
at the end just before any captured conditions are relayed.}
\item{delay_conditions}{A character vector specifying \link[base:conditions]{base::condition}
classes to be captured and relayed at the end after any captured
standard output is relayed.}
\item{interrupts}{Controls whether interrupts should be detected or not.
If TRUE and a interrupt is signaled, progress handlers are asked to
report on the current amount progress when the evaluation was terminated
by the interrupt, e.g. when a user pressed Ctrl-C in an interactive session,
or a batch process was interrupted because it ran out of time.
Note that it's optional for a progress handler to support this and only
some do.}
\item{interval}{(numeric) The minimum time (in seconds) between
successive progression updates from handlers.}
\item{enable}{(logical) If FALSE, then progress is not reported. The
default is to report progress in interactive mode but not batch mode.
See below for more details.}
}
\value{
Returns the value of the expression.
}
\description{
Report on Progress while Evaluating an R Expression
}
\details{
If the global progression handler is enabled, it is temporarily disabled
while evaluating the \code{expr} expression.
\strong{IMPORTANT: This function is meant for end users only. It should not
be used by R packages, which only task is to \emph{signal} progress updates,
not to decide if, when, and how progress should be reported.}
\code{without_progress()} evaluates an expression while ignoring all
progress updates.
}
\section{Progression handler functions}{
Formally, progression handlers are calling handlers that are called
when a \link{progression} condition is signaled. These handlers are functions
that takes one argument which is the \link{progression} condition.
}
\section{Progress updates in batch mode}{
When running R from the command line, R runs in a non-interactive mode
(\code{interactive()} returns \code{FALSE}). The default behavior of
\code{with_progress()} is to \emph{not} report on progress in non-interactive mode.
To have progress being reported on also then, set R options
\option{progressr.enable} or environment variable \env{R_PROGRESSR_ENABLE}
to \code{TRUE}. Alternatively, one can set argument \code{enable=TRUE} when calling
\code{with_progress()}. For example,
\if{html}{\out{
}}
will.
}
\examples{
## The slow_sum() example function
slow_sum <- progressr::slow_sum
print(slow_sum)
x <- 1:10
## Without progress updates
y <- slow_sum(x)
## Progress reported via txtProgressBar (default)
handlers("txtprogressbar") ## default
with_progress({
y <- slow_sum(x)
})
## Progress reported via tcltk::tkProgressBar
if (capabilities("tcltk") && requireNamespace("tcltk", quietly = TRUE)) {
handlers("tkprogressbar")
with_progress({
y <- slow_sum(x)
})
}
## Progress reported via progress::progress_bar)
if (requireNamespace("progress", quietly = TRUE)) {
handlers("progress")
with_progress({
y <- slow_sum(x)
})
}
## Progress reported via txtProgressBar and beepr::beep
if (requireNamespace("beepr", quietly = TRUE)) {
handlers("beepr", "txtprogressbar")
with_progress({
y <- slow_sum(x)
})
}
## Progress reported via customized utils::txtProgressBar and beepr::beep,
## if available.
handlers(handler_txtprogressbar(style = 3L))
if (requireNamespace("beepr", quietly = TRUE)) {
handlers("beepr", append = TRUE)
}
with_progress({
y <- slow_sum(1:30)
})
}
\seealso{
\code{\link[base:conditions]{base::withCallingHandlers()}}
}
progressr/man/progress_aggregator.Rd 0000644 0001762 0000144 00000001336 14372060073 017415 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress_aggregator.R
\name{progress_aggregator}
\alias{progress_aggregator}
\title{Aggregate Progression Conditions}
\usage{
progress_aggregator(progress)
}
\arguments{
\item{progress}{A \link{progressor} function.}
}
\value{
A function of class \code{progress_aggregator}.
}
\description{
Aggregate Progression Conditions
}
\examples{
library(progressr)
message("progress_aggregator() ...")
with_progress({
progress <- progressor(steps = 4L)
relay_progress <- progress_aggregator(progress)
progress()
relay_progress(slow_sum(1:3))
relay_progress(slow_sum(1:10))
progress()
})
message("progress_aggregator() ... done")
}
\keyword{internal}
progressr/man/progressr.options.Rd 0000644 0001762 0000144 00000013010 14431205002 017044 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/options.R
\name{progressr.options}
\alias{progressr.options}
\alias{progressr.clear}
\alias{progressr.debug}
\alias{progressr.demo.delay}
\alias{progressr.delay_stdout}
\alias{progressr.delay_conditions}
\alias{progressr.enable}
\alias{progressr.enable_after}
\alias{progressr.interrupts}
\alias{progressr.interval}
\alias{progressr.intrusiveness}
\alias{progressr.intrusiveness.audio}
\alias{progressr.intrusiveness.debug}
\alias{progressr.intrusiveness.file}
\alias{progressr.intrusiveness.gui}
\alias{progressr.intrusiveness.notifier}
\alias{progressr.intrusiveness.terminal}
\alias{progressr.handlers}
\alias{progressr.times}
\title{Options and environment variables used by the 'progressr' packages}
\description{
Below are environment variables and \R options that are used by the
\pkg{progressr} package.
Below are all \R options that are currently used by the \pkg{progressr} package.\cr
\cr
\emph{WARNING: Note that the names and the default values of these options may change in future versions of the package. Please use with care until further notice.}
}
\section{Options for controlling progression reporting}{
\describe{
\item{\option{progressr.handlers}:}{
(function or list of functions)
Zero or more progression handlers that will report on any progression updates. If empty list, progress updates are ignored. If NULL, the default (\code{handler_txtprogressbar}) progression handlers is used. The recommended way to set this option is via \code{\link[=handlers]{handlers()}}. (Default: NULL)
}
}
}
\section{Options for controlling progression handlers}{
\describe{
\item{\option{progressr.clear}:}{
(logical)
If TRUE, any output, typically visual, produced by a reporter will be cleared/removed upon completion, if possible. (Default: TRUE)
}
\item{\option{progressr.enable}:}{
(logical)
If FALSE, then progress is not reported.
(Default: TRUE in interactive mode, otherwise FALSE)
}
\item{\option{progressr.enable_after}:}{
(numeric)
Delay (in seconds) before progression updates are reported.
(Default: \code{0.0})
}
\item{\option{progressr.times}:}{
(numeric)
The maximum number of times a handler should report progression updates. If zero, then progress is not reported.
(Default: \code{+Inf})
}
\item{\option{progressr.interval}:}{
(numeric)
The minimum time (in seconds) between successive progression updates from this handler.
(Default: \code{0.0})
}
\item{\option{progressr.intrusiveness}:}{
(numeric)
A non-negative scalar on how intrusive (disruptive) the reporter to the user. This multiplicative scalar applies to the \emph{interval} and \emph{times} parameters. (Default: \code{1.0})\cr
\describe{
\item{\option{progressr.intrusiveness.audio}:}{(numeric) intrusiveness for auditory progress handlers (Default: \code{5.0})}
\item{\option{progressr.intrusiveness.file}:}{(numeric) intrusiveness for file-based progress handlers (Default: \code{5.0})}
\item{\option{progressr.intrusiveness.gui}:}{(numeric) intrusiveness for graphical-user-interface progress handlers (Default: \code{1.0})}
\item{\option{progressr.intrusiveness.notifier}:}{(numeric) intrusiveness for progress handlers that creates notifications (Default: \code{10.0})}
\item{\option{progressr.intrusiveness.terminal}:}{(numeric) intrusiveness for progress handlers that outputs to the terminal (Default: \code{1.0})}
\item{\option{progressr.intrusiveness.debug}:}{(numeric) intrusiveness for "debug" progress handlers (Default: \code{0.0})}
}
}
}
}
\section{Options for controlling how standard output and conditions are relayed}{
\describe{
\item{\option{progressr.delay_conditions}:}{
(character vector)
condition classes to be captured and relayed at the end after any captured standard output is relayed. (Default: \code{c("condition")})
}
\item{\option{progressr.delay_stdout}:}{
(logical)
If TRUE, standard output is captured and relayed at the end just before any captured conditions are relayed. (Default: TRUE)
}
}
}
\section{Options for controlling interrupts}{
\describe{
\item{\option{progressr.interrupts}:}{
(logical)
Controls whether interrupts should be detected or not.
If FALSE, then interrupts are not detected and progress information
is generated. (Default: \code{TRUE})
}
\item{\option{progressr.delay_stdout}:}{
(logical)
If TRUE, standard output is captured and relayed at the end just before any captured conditions are relayed. (Default: TRUE)
}
}
}
\section{Options for debugging progression updates}{
\describe{
\item{\option{progressr.debug}:}{(logical) If TRUE, extensive debug messages are generated. (Default: FALSE)}
}
}
\section{Options for progressr examples and demos}{
\describe{
\item{\option{progressr.demo.delay}:}{(numeric) Delay (in seconds) between each iteration of \code{\link[=slow_sum]{slow_sum()}}. (Default: \code{1.0})}
}
}
\section{Environment variables that set R options}{
Some of the above \R \option{progressr.*} options can be set by corresponding
environment variable \env{R_PROGRESSR_*} \emph{when the \pkg{progressr} package
is loaded}.
For example, if \code{R_PROGRESSR_ENABLE = "true"}, then option
\option{progressr.enable} is set to \code{TRUE} (logical).
For example, if \code{R_PROGRESSR_ENABLE_AFTER = "2.0"}, then option
\option{progressr.enable_after} is set to \code{2.0} (numeric).
}
\seealso{
To set \R options when \R starts (even before the \pkg{progressr} package is loaded), see the \link[base]{Startup} help page. The \href{https://cran.r-project.org/package=startup}{\pkg{startup}} package provides a friendly mechanism for configuring \R at startup.
}
progressr/man/handler_pbmcapply.Rd 0000644 0001762 0000144 00000004106 14422114703 017025 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_pbmcapply.R
\name{handler_pbmcapply}
\alias{handler_pbmcapply}
\title{Progression Handler: Progress Reported via 'pbmcapply' Progress Bars (Text) in the Terminal}
\usage{
handler_pbmcapply(
char = "=",
substyle = 3L,
style = "ETA",
file = stderr(),
intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
target = "terminal",
...
)
}
\arguments{
\item{char}{(character) The symbols to form the progress bar for
\code{\link[utils:txtProgressBar]{utils::txtProgressBar()}}.}
\item{substyle}{(integer) The progress-bar substyle according to
\code{\link[pbmcapply:progressBar]{pbmcapply::progressBar()}}.}
\item{style}{(character) The progress-bar style according to}
\item{file}{(connection) A \link[base:connections]{base::connection} to where output should be sent.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{\link[pbmcapply:progressBar]{pbmcapply::progressBar()}}.
}
\section{Requirements}{
This progression handler requires the \pkg{pbmcapply} package.
}
\section{Appearance}{
Below are a few examples on how to use and customize this progress handler.
In all cases, we use \code{handlers(global = TRUE)}.
Since \code{style = "txt"} corresponds to using \code{\link[=handler_txtprogressbar]{handler_txtprogressbar()}}
with \code{style = substyle}, the main usage of this handler is with
\code{style = "ETA"} (default) for which \code{substyle} is ignored.
\if{html}{\out{
}}\preformatted{handlers("pbmcapply")
y <- slow_sum(1:25)
}\if{html}{\out{
}}
\if{html}{\figure{handler_pbmcapply-default.svg}}
}
\examples{
if (requireNamespace("pbmcapply", quietly = TRUE)) {
handlers("pbmcapply")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
progressr/man/handler_shiny.Rd 0000644 0001762 0000144 00000003505 14372060073 016176 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_shiny.R
\name{handler_shiny}
\alias{handler_shiny}
\title{Progression Handler: Progress Reported via 'shiny' Widgets (GUI) in the HTML Browser}
\usage{
handler_shiny(
intrusiveness = getOption("progressr.intrusiveness.gui", 1),
target = "gui",
inputs = list(message = NULL, detail = "message"),
enable = getOption("progressr.enable", TRUE),
...
)
}
\arguments{
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{inputs}{(named list) Specifies from what sources the Shiny progress
elements 'message' and 'detail' should be updated. Valid sources are
\code{"message"}, \code{"sticky_message"} and \code{"non_sticky_message"}, where
\code{"message"} is short for \code{c("non_sticky_message", "sticky_message")}. For
example, \code{inputs = list(message = "sticky_message", detail = "message")}
will update the Shiny 'message' component from sticky messages only,
whereas the 'detail' component is updated using any message.}
\item{enable}{(logical) If FALSE, then progress is not reported.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \pkg{shiny} and \code{\link[shiny:withProgress]{shiny::withProgress()}}.
}
\details{
For most Shiny application there is little need to use this Shiny handler
directly. Instead, it is sufficient to use \code{\link[=withProgressShiny]{withProgressShiny()}}.
}
\section{Requirements}{
This progression handler requires the \pkg{shiny} package.
}
\examples{
\donttest{\dontrun{
handlers(handler_shiny())
with_progress(y <- slow_sum(1:100))
}}
}
\keyword{internal}
progressr/man/roxygen/ 0000755 0001762 0000144 00000000000 14372060073 014550 5 ustar ligges users progressr/man/roxygen/meta.R 0000644 0001762 0000144 00000002107 14372060073 015621 0 ustar ligges users
if (exists(".knitr_asciicast_process", envir = .GlobalEnv)) {
rm(list = ".knitr_asciicast_process", envir = .GlobalEnv)
}
asciicast::init_knitr_engine(
echo = TRUE,
echo_input = FALSE,
interactive = TRUE,
timeout = as.integer(Sys.getenv("ASCIICAST_TIMEOUT", 10)),
startup = quote({
library(progressr)
options(width = 70)
options(progressr.enable = TRUE)
options(progressr.demo.delay = 0.15)
options(progressr.show_after = 0.0)
options(progressr.clear = FALSE)
## To simplify examples
options(progressr.slow_sum.stdout = FALSE)
options(progressr.slow_sum.message = FALSE)
options(progressr.slow_sum.sticky = FALSE)
handlers(global = TRUE)
})
)
knitr::opts_chunk$set(
asciicast_knitr_output = "html",
asciicast_include_style = FALSE,
asciicast_theme = "pkgdown"
)
list(
markdown = TRUE,
knitr_chunk_options = list(
cache = TRUE,
cache_lazy = FALSE,
cache.path = file.path(getwd(), "man/_cache/"),
fig.path = file.path(getwd(), "man/figures"),
error = TRUE
),
restrict_image_formats = TRUE
)
progressr/man/progress.Rd 0000644 0001762 0000144 00000001314 14372060073 015207 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progress.R
\name{progress}
\alias{progress}
\title{Creates and Signals a Progression Condition}
\usage{
progress(..., call = sys.call())
}
\arguments{
\item{call}{(expression) A call expression.}
\item{\ldots}{Arguments pass to \code{\link[=progression]{progression()}}.}
}
\value{
A \link[base:conditions]{base::condition} of class \code{progression}.
}
\description{
\emph{WARNING:} \code{progress()} is defunct - don't use.
}
\seealso{
To create a progression condition, use \code{\link[=progression]{progression()}}.
To signal a progression condition, use \code{\link[base:conditions]{base::signalCondition()}}.
}
\keyword{internal}
progressr/man/progress_progressr.Rd 0000644 0001762 0000144 00000002353 14372060073 017321 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plyr_progress_progressr.R
\name{progress_progressr}
\alias{progress_progressr}
\title{Use Progressr with Plyr Map-Reduce Functions}
\usage{
progress_progressr(...)
}
\arguments{
\item{\ldots}{Not used.}
}
\value{
A named \link[base:list]{base::list} that can be passed as argument \code{.progress}
to any of \pkg{plyr} function accepting that argument.
}
\description{
A "progress bar" for \pkg{plyr}'s \code{.progress} argument.
}
\section{Limitations}{
One can use use \code{\link[doFuture:registerDoFuture]{doFuture::registerDoFuture()}} to run \pkg{plyr} functions
in parallel, e.g. \code{plyr::l_ply(..., .parallel = TRUE)}. Unfortunately,
using \code{.parallel = TRUE} disables progress updates because, internally,
\pkg{plyr} forces \code{.progress = "none"} whenever \code{.parallel = TRUE}.
Thus, despite the \pkg{future} ecosystem and \pkg{progressr} would support
it, it is not possible to run \pkg{dplyr} in parallel \emph{and} get progress
updates at the same time.
}
\examples{
if (requireNamespace("plyr", quietly=TRUE)) {
with_progress({
y <- plyr::llply(1:10, function(x) {
Sys.sleep(0.1)
sqrt(x)
}, .progress = "progressr")
})
}
}
progressr/man/handler_void.Rd 0000644 0001762 0000144 00000001605 14372060073 016004 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_void.R
\name{handler_void}
\alias{handler_void}
\title{Progression Handler: No Progress Report}
\usage{
handler_void(intrusiveness = 0, target = "void", enable = FALSE, ...)
}
\arguments{
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{enable}{(logical) If FALSE, then progress is not reported.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
Progression Handler: No Progress Report
}
\details{
This progression handler gives not output - it is invisible and silent.
}
\examples{
\donttest{\dontrun{
handlers(handler_void())
with_progress(y <- slow_sum(1:100))
print(y)
}}
}
progressr/man/handler_cli.Rd 0000644 0001762 0000144 00000003360 14422114703 015606 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_cli.R
\name{handler_cli}
\alias{handler_cli}
\title{Progression Handler: Progress Reported via 'cli' Progress Bars (Text) in the Terminal}
\usage{
handler_cli(
show_after = 0,
intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
target = "terminal",
...
)
}
\arguments{
\item{show_after}{(numeric) Number of seconds to wait before displaying
the progress bar.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{\link[cli:cli_progress_bar]{cli::cli_progress_bar()}}.
}
\section{Requirements}{
This progression handler requires the \pkg{cli} package.
}
\section{Appearance}{
Below are a few examples on how to use and customize this progress handler.
In all cases, we use \code{handlers(global = TRUE)}.
\if{html}{\out{
}}\preformatted{handlers("cli")
y <- slow_sum(1:25)
}\if{html}{\out{
}}\preformatted{handlers(handler_cli(format = "\{cli::pb_spin\} \{cli::pb_bar\} \{cli::pb_current\}/\{cli::pb_total\} \{cli::pb_status\}"))
y <- slow_sum(1:25)
}\if{html}{\out{
}}
\if{html}{\figure{handler_cli-format-1.svg}}
}
\examples{
if (requireNamespace("cli", quietly = TRUE)) {
handlers(handler_cli(format = "{cli::pb_spin} {cli::pb_bar} {cli::pb_percent} {cli::pb_status}"))
with_progress({ y <- slow_sum(1:10) })
print(y)
}
}
progressr/man/register_global_progression_handler.Rd 0000644 0001762 0000144 00000002500 14372060073 022634 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/global_progression_handler.R
\name{register_global_progression_handler}
\alias{register_global_progression_handler}
\title{Add or Remove a Global 'progression' Handler}
\usage{
register_global_progression_handler(action = c("add", "remove", "query"))
}
\arguments{
\item{action}{(character string)
If \code{"add"}, a global handler is added.
If \code{"remove"}, it is removed, if it exists.
If \code{"query"}, checks whether a handler is registered or not.}
}
\value{
Returns TRUE if a handler is registered, otherwise FALSE.
If \code{action = "query"}, the value is visible, otherwise invisible.
}
\description{
Add or Remove a Global 'progression' Handler
}
\section{Requirements}{
This function requires R (>= 4.0.0) - the version in which global calling
handlers where introduces.
}
\examples{
\dontshow{if (getRversion() >= "4.0.0" && !is.element("pkgdown", loadedNamespaces()))}
handlers(global = TRUE)
## This renders progress updates for each of the three calls slow_sum()
for (ii in 1:3) {
xs <- seq_len(ii + 3)
message(sprintf("\%d. slow_sum()", ii))
y <- slow_sum(xs, stdout = TRUE, message = TRUE)
print(y)
}
\dontshow{if (getRversion() >= "4.0.0" && !is.element("pkgdown", loadedNamespaces()))}
handlers(global = FALSE)
}
\keyword{internal}
progressr/man/handler_txtprogressbar.Rd 0000644 0001762 0000144 00000005343 14422114703 020133 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_txtprogressbar.R
\name{handler_txtprogressbar}
\alias{handler_txtprogressbar}
\title{Progression Handler: Progress Reported as Plain Progress Bars (Text) in the Terminal}
\usage{
handler_txtprogressbar(
char = "=",
style = 3L,
file = stderr(),
intrusiveness = getOption("progressr.intrusiveness.terminal", 1),
target = "terminal",
...
)
}
\arguments{
\item{char}{(character) The symbols to form the progress bar for
\code{\link[utils:txtProgressBar]{utils::txtProgressBar()}}. Contrary to \code{txtProgressBar()}, this handler
supports also ANSI-colored symbols.}
\item{style}{(integer) The progress-bar style according to
\code{\link[utils:txtProgressBar]{utils::txtProgressBar()}}.}
\item{file}{(connection) A \link[base:connections]{base::connection} to where output should be sent.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler for \code{\link[utils:txtProgressBar]{utils::txtProgressBar()}}.
}
\section{Appearance}{
Below are a few examples on how to use and customize this progress handler.
In all cases, we use \code{handlers(global = TRUE)}.
\if{html}{\out{
}}\preformatted{handlers("txtprogressbar")
y <- slow_sum(1:25)
}\if{html}{\out{
}}\preformatted{handlers(handler_txtprogressbar(char = cli::col_red(cli::symbol$heart)))
y <- slow_sum(1:25)
}\if{html}{\out{
}}
\if{html}{\figure{handler_txtprogressbar-char-ansi.svg}}
}
\examples{
handlers("txtprogressbar")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
progressr/man/progressr.Rd 0000644 0001762 0000144 00000005571 14372060073 015402 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/progressr-package.R
\docType{package}
\name{progressr}
\alias{progressr}
\alias{progressr-package}
\title{progressr: A Unifying API for Progress Updates}
\description{
The \pkg{progressr} package provides a minimal, unifying API for scripts
and packages to report progress updates from anywhere including when
using parallel processing.
}
\details{
The package is designed such that \emph{the developer} can to focus on \emph{what}
progress should be reported on without having to worry about \emph{how} to
present it.
The \emph{end user} has full control of \emph{how}, \emph{where}, and \emph{when} to render
these progress updates. For instance, they can chose to report progress
in the terminal using \code{\link[utils:txtProgressBar]{utils::txtProgressBar()}} or
\code{\link[progress:progress_bar]{progress::progress_bar()}} or via the graphical user interface (GUI)
using \code{utils::winProgressBar()} or \code{\link[tcltk:tkProgressBar]{tcltk::tkProgressBar()}}.
An alternative to above visual rendering of progress, is to report it
using \code{\link[beepr:beep]{beepr::beep()}} sounds.
It is possible to use a combination of above progression handlers, e.g.
a progress bar in the terminal together with audio updates.
Besides the existing handlers, it is possible to develop custom
progression handlers.
The \pkg{progressr} package uses R's condition framework for signaling
progress updated. Because of this, progress can be reported from almost
anywhere in R, e.g. from classical for and while loops, from map-reduce
APIs like the \code{\link[=lapply]{lapply()}} family of functions, \pkg{purrr}, \pkg{plyr}, and
\pkg{foreach}.
The \pkg{progressr} package will also work with parallel processing via
the \pkg{future} framework, e.g. \code{\link[future.apply:future_lapply]{future.apply::future_lapply()}},
\code{\link[furrr:future_map]{furrr::future_map()}}, and \code{\link[foreach:foreach]{foreach::foreach()}} with \pkg{doFuture}.
The \pkg{progressr} package is compatible with Shiny applications.
}
\section{Progression Handlers}{
In the terminal:
\itemize{
\item \link{handler_txtprogressbar} (default)
\item \link{handler_pbcol}
\item \link{handler_pbmcapply}
\item \link{handler_progress}
\item \link{handler_ascii_alert}
\item \link{handler_debug}
}
In a graphical user interface (GUI):
\itemize{
\item \link{handler_rstudio}
\item \link{handler_tkprogressbar}
\item \link{handler_winprogressbar}
}
As sound:
\itemize{
\item \link{handler_beepr}
\item \link{handler_ascii_alert}
}
Via the file system:
\itemize{
\item \link{handler_filesize}
}
In Shiny:
\itemize{
\item \link{withProgressShiny}
}
}
\examples{
library(progressr)
xs <- 1:5
with_progress({
p <- progressor(along = xs)
y <- lapply(xs, function(x) {
Sys.sleep(0.1)
p(sprintf("x=\%g", x))
sqrt(x)
})
})
}
\keyword{iteration}
\keyword{programming}
progressr/man/withProgressShiny.Rd 0000644 0001762 0000144 00000004733 14453030133 017060 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/withProgressShiny.R
\name{withProgressShiny}
\alias{withProgressShiny}
\title{Use Progressr in Shiny Apps: Plug-in Backward-Compatible Replacement for shiny::withProgress()}
\usage{
withProgressShiny(
expr,
...,
message = NULL,
detail = NULL,
inputs = list(message = NULL, detail = "message"),
env = parent.frame(),
quoted = FALSE,
handlers = c(shiny = handler_shiny, progressr::handlers(default = NULL))
)
}
\arguments{
\item{expr, \ldots, env, quoted}{Arguments passed to \code{\link[shiny:withProgress]{shiny::withProgress()}} as is.}
\item{message, detail}{(character string) The message and the detail message to be passed to \code{\link[shiny:withProgress]{shiny::withProgress()}}.}
\item{inputs}{(named list) Specifies from what sources the Shiny progress
elements 'message' and 'detail' should be updated. Valid sources are
\code{"message"}, \code{"sticky_message"} and \code{"non_sticky_message"}, where
\code{"message"} is short for \code{c("non_sticky_message", "sticky_message")}. For
example, \code{inputs = list(message = "sticky_message", detail = "message")}
will update the Shiny 'message' component from sticky messages only,
whereas the 'detail' component is updated using any message.}
\item{handlers}{Zero or more progression handlers used to report on progress.}
}
\value{
The value of \link[shiny:withProgress]{shiny::withProgress}.
}
\description{
A plug-in, backward-compatible replacement for \code{\link[shiny:withProgress]{shiny::withProgress()}}.
}
\section{Requirements}{
This function requires the \pkg{shiny} package and will use the
\code{\link[=handler_shiny]{handler_shiny()}} \strong{progressr} handler internally to report on updates.
}
\examples{
library(shiny)
library(progressr)
app <- shinyApp(
ui = fluidPage(
plotOutput("plot")
),
server = function(input, output) {
output$plot <- renderPlot({
X <- 1:15
withProgressShiny(message = "Calculation in progress",
detail = "Starting ...",
value = 0, {
p <- progressor(along = X)
y <- lapply(X, FUN=function(x) {
Sys.sleep(0.25)
p(sprintf("x=\%d", x))
})
})
plot(cars)
## Terminate the Shiny app
Sys.sleep(1.0)
stopApp(returnValue = invisible())
})
}
)
local({
oopts <- options(device.ask.default = FALSE)
on.exit(options(oopts))
if (interactive()) print(app)
})
}
progressr/man/handler_ascii_alert.Rd 0000644 0001762 0000144 00000002242 14372060073 017320 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/handler_ascii_alert.R
\name{handler_ascii_alert}
\alias{handler_ascii_alert}
\title{Progression Handler: Progress Reported as ASCII BEL Symbols (Audio or Blink) in the Terminal}
\usage{
handler_ascii_alert(
symbol = "\\a",
file = stderr(),
intrusiveness = getOption("progressr.intrusiveness.audio", 5),
target = c("terminal", "audio"),
...
)
}
\arguments{
\item{symbol}{(character string) The character symbol to be outputted,
which by default is the ASCII BEL character (\code{'\\a'} = \code{'\\007'}) character.}
\item{file}{(connection) A \link[base:connections]{base::connection} to where output should be sent.}
\item{intrusiveness}{(numeric) A non-negative scalar on how intrusive
(disruptive) the reporter to the user.}
\item{target}{(character vector) Specifies where progression updates are
rendered.}
\item{\ldots}{Additional arguments passed to \code{\link[=make_progression_handler]{make_progression_handler()}}.}
}
\description{
A progression handler based on \code{cat("\\a", file=stderr())}.
}
\examples{
handlers("ascii_alert")
with_progress({ y <- slow_sum(1:10) })
print(y)
}
progressr/man/figures/ 0000755 0001762 0000144 00000000000 14422115703 014516 5 ustar ligges users progressr/man/figures/lifecycle-maturing-blue.svg 0000644 0001762 0000144 00000001706 14372060073 021756 0 ustar ligges users