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 for 'foreach' functions

The progressify package allows you to easily add progress reporting to sequential and parallel map-reduce code by piping to the progressify() function. Easy!

TL;DR

library(progressify)
handlers(global = TRUE)
library(foreach)

slow_fcn <- function(x) {
  Sys.sleep(0.1)  # emulate work
  x^2
}

xs <- 1:100
ys <- foreach(x = xs) %do% slow_fcn(x) |> progressify()

Introduction

This vignette demonstrates how to use this approach to add progress reporting to the foreach foreach() construct and the doFuture %dofuture% operator.

For example, consider:

library(foreach)
xs <- 1:100
ys <- foreach(x = xs) %do% slow_fcn(x)

This foreach() construct provides no feedback on how far it has progressed. We can easily add progress reporting by piping to progressify():

library(foreach)

library(progressify)
handlers(global = TRUE)

xs <- 1:100
ys <- foreach(x = xs) %do% slow_fcn(x) |> progressify()

Using the default progress handler, the progress reporting will appear as:

  |=====                    |  20%

With doFuture

The same approach works with the doFuture package for parallel foreach evaluation:

library(doFuture)
plan(multisession)

library(progressify)
handlers(global = TRUE)

xs <- 1:100
ys <- foreach(x = xs) %dofuture% slow_fcn(x) |> progressify()

Supported Functions

The progressify() function supports the following foreach operators:

and the following doFuture operator:

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.