{"id":22978251,"url":"https://github.com/futureverse/dofuture","last_synced_at":"2025-12-12T01:03:51.667Z","repository":{"id":60722824,"uuid":"58106914","full_name":"futureverse/doFuture","owner":"futureverse","description":":rocket: R package: doFuture - Use Foreach to Parallelize via Future Framework","archived":false,"fork":false,"pushed_at":"2025-04-05T18:34:09.000Z","size":2056,"stargazers_count":83,"open_issues_count":7,"forks_count":6,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-07T19:14:52.658Z","etag":null,"topics":["batchjobs","batchtools","biocparallel","cran","distributed-computing","foreach","hpc","hpc-clusters","package","parallel","plyr","r"],"latest_commit_sha":null,"homepage":"https://doFuture.futureverse.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/futureverse.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-05T05:35:46.000Z","updated_at":"2025-04-05T18:34:13.000Z","dependencies_parsed_at":"2023-02-13T17:30:29.575Z","dependency_job_id":"d0d5ce07-4a2a-4f1e-b67a-ef254ba19a84","html_url":"https://github.com/futureverse/doFuture","commit_stats":{"total_commits":625,"total_committers":3,"mean_commits":"208.33333333333334","dds":"0.060799999999999965","last_synced_commit":"9bc4f579391bc052b4495260a0bba869ee862778"},"previous_names":["futureverse/dofuture","henrikbengtsson/dofuture"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2FdoFuture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2FdoFuture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2FdoFuture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2FdoFuture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futureverse","download_url":"https://codeload.github.com/futureverse/doFuture/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713258,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batchjobs","batchtools","biocparallel","cran","distributed-computing","foreach","hpc","hpc-clusters","package","parallel","plyr","r"],"created_at":"2024-12-15T01:06:07.738Z","updated_at":"2025-12-12T01:03:51.580Z","avatar_url":"https://github.com/futureverse.png","language":"R","readme":"\u003cdiv id=\"badges\"\u003e\u003c!-- pkgdown markup --\u003e\n\u003ca href=\"https://CRAN.R-project.org/web/checks/check_results_doFuture.html\"\u003e\u003cimg border=\"0\" src=\"https://www.r-pkg.org/badges/version/doFuture\" alt=\"CRAN check status\"/\u003e\u003c/a\u003e \u003ca href=\"https://github.com/futureverse/doFuture/actions?query=workflow%3AR-CMD-check\"\u003e\u003cimg border=\"0\" src=\"https://github.com/futureverse/doFuture/actions/workflows/R-CMD-check.yaml/badge.svg?branch=develop\" alt=\"R CMD check status\"/\u003e\u003c/a\u003e     \u003ca href=\"https://app.codecov.io/gh/futureverse/doFuture\"\u003e\u003cimg border=\"0\" src=\"https://codecov.io/gh/futureverse/doFuture/branch/develop/graph/badge.svg\" alt=\"Coverage Status\"/\u003e\u003c/a\u003e \n\u003c/div\u003e\n\n# doFuture: Use Foreach to Parallelize via the Future Framework \n\n## Introduction\n\nThe **[future]** package provides a generic API for using futures in\nR.  A future is a simple yet powerful mechanism to evaluate an R\nexpression and retrieve its value at some point in time.  Futures can\nbe resolved in many different ways depending on which strategy is\nused.  There are various types of synchronous and asynchronous futures\nto choose from in the **[future]** package.  Additional future\nbackends are implemented in other packages.  For instance, the\n**[future.batchtools]** package provides futures for _any_ type of\nbackend that the **[batchtools]** package supports.  For an\nintroduction to futures in R, please consult the vignettes of the\n**[future]** package.\n\nThe **[foreach]** package implements a map-reduce API with functions\n`foreach()` and `times()` that provides us with powerful methods for\niterating over one or more sets of elements with the option to do it\nin parallel.\n\n\n## Two alternatives\n\nThe **[doFuture]** package provides two alternatives for using futures\nwith **foreach**:\n\n 1. `y \u003c- foreach(...) %dofuture% { ... }`\n\n 2. `registerDoFuture()` + `y \u003c- foreach(...) %dopar% { ... }`.\n \n\n\n### Alternative 1: `%dofuture%`\n\nThe _first alternative_ (recommended), which uses `%dofuture%`, avoids\nhaving to use `registerDoFuture()`.  The `%dofuture%` operator\nprovides a more consistent behavior than `%dopar%`, e.g. there is a\nunique set of foreach arguments instead of one per possible adapter.\nIdentification of globals, random number generation (RNG), and error\nhandling is handled by the future ecosystem, just like with other\nmap-reduce solutions such as **[future.apply]** and **[furrr]**.  An\nexample is:\n\n```r\nlibrary(doFuture)\nplan(multisession)\n\ny \u003c- foreach(x = 1:4, y = 1:10) %dofuture% {\n  z \u003c- x + y\n  slow_sqrt(z)\n}\n```\n\nThis alternative is the recommended way to let `foreach()` parallelize\nvia the future framework, especially if you start out from scratch.\n\nSee `help(\"%dofuture%\", package = \"doFuture\")` for more details and\nexamples on this approach.\n\n\n### Alternative 2: `registerDoFuture()` + `%dopar%`\n\nThe _second alternative_ is based on the traditional **foreach**\napproach where one registers a foreach adapter to be used by\n`%dopar%`.  A popular adapter is `doParallel::registerDoParallel()`,\nwhich parallelizes on the local machine using the **parallel**\npackage.  This package provides `registerDoFuture()`, which\nparallelizes using the **future** package, meaning any\nfuture-compliant parallel backend can be used.\n\nAn example is:\n\n```r\nlibrary(doFuture)\nregisterDoFuture()\nplan(multisession)\n\ny \u003c- foreach(x = 1:4, y = 1:10) %dopar% {\n  z \u003c- x + y\n  slow_sqrt(z)\n}\n```\n\nThis alternative is useful if you already have a lot of R code that\nuses `%dopar%` and you just want to switch to using the future\nframework for parallelization.  Using `registerDoFuture()` is also\nuseful when you wish to use the future framework with packages and\nfunctions that uses `foreach()` and `%dopar%` internally,\ne.g. **[caret]**, **[plyr]**, **[NMF]**, and **[glmnet]**.  It can\nalso be used to configure the Bioconductor **[BiocParallel]** package,\nand any package that rely on it, to parallelize via the future\nframework.\n\nSee `help(\"registerDoFuture\", package = \"doFuture\")` for more details\nand examples on this approach.\n\n\n\n[doFuture]: https://doFuture.futureverse.org\n[future]: https://future.futureverse.org\n[foreach]: https://cran.r-project.org/package=foreach\n[batchtools]: https://cran.r-project.org/package=batchtools\n[future.batchtools]: https://future.batchtools.futureverse.org\n[future.apply]: https://future.apply.futureverse.org\n[furrr]: https://furrr.futureverse.org\n[caret]: https://cran.r-project.org/package=caret\n[plyr]: https://cran.r-project.org/package=plyr\n[NMF]: https://cran.r-project.org/package=NMF\n[glmnet]: https://cran.r-project.org/package=glmnet\n[BiocParallel]: https://bioconductor.org/packages/BiocParallel/\n\n## Installation\nR package doFuture is available on [CRAN](https://cran.r-project.org/package=doFuture) and can be installed in R as:\n```r\ninstall.packages(\"doFuture\")\n```\n\n\n### Pre-release version\n\nTo install the pre-release version that is available in Git branch `develop` on GitHub, use:\n```r\nremotes::install_github(\"futureverse/doFuture\", ref=\"develop\")\n```\nThis will install the package from source.  \n\n\u003c!-- pkgdown-drop-below --\u003e\n\n\n## Contributing\n\nTo contribute to this package, please see [CONTRIBUTING.md](CONTRIBUTING.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutureverse%2Fdofuture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffutureverse%2Fdofuture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutureverse%2Fdofuture/lists"}