The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
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[@]dogado.de.

Parallelize 'crossmap' functions

The 'crossmap' image + The 'futurize' hexlogo = The 'future' logo

The futurize package allows you to easily turn sequential code into parallel code by piping the sequential code to the futurize() function. Easy!

TL;DR

library(futurize)
plan(multisession)
library(crossmap)

xs <- list(1:5, 1:5)
ys <- xmap(xs, ~ .y * .x) |> futurize()

Introduction

This vignette demonstrates how to use this approach to parallelize crossmap functions such as xmap() and xwalk().

The crossmap xmap() function can be used to iterate over every combination of elements in an input list. For example,

library(crossmap)
xs <- list(1:5, 1:5)
ys <- xmap(xs, ~ .y * .x)

Here xmap() evaluates sequentially over each combination of (.y, .x) elements. We can easily make it evaluate in parallel, by using:

library(futurize)
library(crossmap)
xs <- list(1:5, 1:5)
ys <- xmap(xs, ~ .y * .x) |> futurize()

This will distribute the calculations across the available parallel workers, given that we have set parallel workers, e.g.

plan(multisession)

The built-in multisession backend parallelizes on your local computer and it works on all operating systems. There are [other parallel backends] to choose from, including alternatives to parallelize locally as well as distributed across remote machines, e.g.

plan(future.mirai::mirai_multisession)

and

plan(future.batchtools::batchtools_slurm)

Supported Functions

The futurize() function supports parallelization of the following crossmap functions:

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.
Health stats visible at Monitor.