Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

future.apply: Apply Function to Elements in Parallel using Futures

Introduction

The purpose of this package is to provide worry-free parallel alternatives to base-R “apply” functions, e.g. apply(),lapply(), andvapply(). The goal is that one should be able to replace any of these in the core with its futurized equivalent and things will just work. For example, instead of doing:

library(datasets)library(stats)y<-lapply(mtcars, FUN=mean, trim=0.10)

one can do:

library(future.apply)plan(multisession)## Run in parallel on local computerlibrary(datasets)library(stats)y<-future_lapply(mtcars, FUN=mean, trim=0.10)

Reproducibility is part of the core design, which means that perfect, parallel random number generation (RNG) is supported regardless of the amount of chunking, type of load balancing, and future backend being used. To enable parallel RNG, use argumentfuture.seed = TRUE.

Role

Where does thefuture.apply package fit in the software stack? You can think of it as a sibling toforeach,furrr,BiocParallel,plyr, etc. Just asparallel providesparLapply(),foreach providesforeach(),BiocParallel providesbplapply(), andplyr providesllply(),future.apply providesfuture_lapply(). Below is a table summarizing this idea:

PackageFunctionsBackends
future.apply

Future-versions of common goto*apply() functions available in base R (of thebase andstats packages):
future_apply(),future_by(),future_eapply(),future_Filter(),future_lapply(),future_kernapply(),future_Map(),future_mapply(),future_.mapply(),future_replicate(),future_sapply(),future_tapply(), andfuture_vapply().
The following function is not implemented:
future_rapply()
Allfuture backends
parallelmclapply(),mcmapply(),clusterMap(),parApply(),parLapply(),parSapply(), …Built-in and conditional on operating system
foreachforeach(),times()Allfuture backends viadoFuture
furrrfuture_imap(),future_map(),future_pmap(),future_map2(), …Allfuture backends
BiocParallelBioconductor’s parallel mappers:
bpaggregate(),bpiterate(),bplapply(), andbpvec()
Allfuture backends viadoFuture (because it supportsforeach) or viaBiocParallel.FutureParam (direct BiocParallelParam support; prototype)
plyr**ply(…, .parallel = TRUE) functions:
aaply(),ddply(),dlply(),llply(), …
Allfuture backends viadoFuture (because it usesforeach internally)

Note that, except for the built-inparallel package, none of these higher-level APIs implement their own parallel backends, but they rather enhance existing ones. Theforeach framework leverages backends such asdoParallel,doMC anddoFuture, and thefuture.apply framework leverages thefuture ecosystem and therefore backends such as built-inparallel,future.callr, andfuture.batchtools.

By separatingfuture_lapply() and friends from thefuture package, it helps clarifying the purpose of thefuture package, which is to define and provide the core Future API, which higher-level parallel APIs can build on and for which any futurized parallel backends can be plugged into.

The API and identity of thefuture.apply package will be kept close to the*apply() functions in base R. In other words, it willneither keep growing nor be expanded with new, more powerful apply-like functions beyond those core ones in base R. Such extended functionality should be part of a separate package.

Installation

R package future.apply is available onCRAN and can be installed in R as:

install.packages("future.apply")

Pre-release version

To install the pre-release version that is available in Git branchdevelop on GitHub, use:

remotes::install_github("futureverse/future.apply", ref="develop")

This will install the package from source.

Links

License

  • GPL (>= 2)

Community

Citation

Developers

Dev status

  • CRAN check status
  • R CMD check status
  • Coverage Status

[8]ページ先頭

©2009-2026 Movatter.jp