The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Progress updates by progressr is designed to work out of the box
for any iterator framework in R, e.g. lapply()
, foreach,
purrr, and plyr. Below you will a set of examples that
illustrate how to use progressr in common use cases.
library(progressr)
handlers(global = TRUE)
my_fcn <- function(xs) {
p <- progressor(along = xs)
lapply(xs, function(x) {
Sys.sleep(0.1)
p(sprintf("x=%g", x))
sqrt(x)
})
}
y <- my_fcn(1:10)
# |==================== | 40%
library(foreach)
library(progressr)
handlers(global = TRUE)
my_fcn <- function(xs) {
p <- progressor(along = xs)
foreach(x = xs) %do% {
Sys.sleep(0.1)
p(sprintf("x=%g", x))
sqrt(x)
}
}
y <- my_fcn(1:10)
# |==================== | 40%
library(purrr)
library(progressr)
handlers(global = TRUE)
my_fcn <- function(xs) {
p <- progressor(along = xs)
map(xs, function(x) {
Sys.sleep(0.1)
p(sprintf("x=%g", x))
sqrt(x)
})
}
y <- my_fcn(1:10)
# |==================== | 40%
library(plyr)
library(progressr)
handlers(global = TRUE)
my_fcn <- function(xs) {
p <- progressor(along = xs)
llply(xs, function(x, ...) {
Sys.sleep(0.1)
p(sprintf("x=%g", x))
sqrt(x)
})
}
y <- my_fcn(1:10)
# |==================== | 40%
Note how this solution does not make use of plyr's .progress
argument, because the above solution is more powerful and more
flexible, e.g. we have more control on progress updates and their
messages. However, if you prefer the traditional plyr approach,
you can use .progress = "progressr"
, e.g. y <- llply(..., .progress = "progressr")
.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.