| future.batchtools | R Documentation |
The future.batchtools package implements the Future API on top of batchtools such that futures can be resolved on for instance high-performance compute (HPC) clusters via job schedulers. The Future API is defined by the future package.
To use batchtools futures, attach future, and
select the type of future you wish to use via
future::plan().
library(futurize) # also attaches 'future'
plan(future.batchtools::batchtools_slurm) # parallelize via Slurm jobs
# A slow function
slow_fcn <- function(x) {
Sys.sleep(1.0)
x^2
}
# Example data
xs <- 1:10
# Sequential and parallel base R apply
ys <- lapply(xs, slow_fcn)
ys <- lapply(xs, slow_fcn) |> futurize()
# Sequential and parallel purrr map
library(purrr)
ys <- xs |> map(slow_fcn)
ys <- xs |> map(slow_fcn) |> futurize()
# Sequential and parallel foreach calls
library(foreach)
ys <- foreach(x = xs) %do% slow_fcn(x)
ys <- foreach(x = xs) %do% slow_fcn(x) |> futurize()
Maintainer: Henrik Bengtsson henrikb@braju.com (ORCID) [copyright holder]
Authors:
Henrik Bengtsson henrikb@braju.com (ORCID) [copyright holder]
Other contributors:
Michel Lang (ORCID) (Code adapted from the 'batchtools' package) [contributor, copyright holder]
Bernd Bischl (ORCID) (Code adapted from the 'batchtools' package) [contributor, copyright holder]
Useful links:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.