-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
107 lines (76 loc) · 3.33 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# R/`delayed`
[![R-CMD-check](https://github.com/tlverse/delayed/workflows/R-CMD-check/badge.svg)](https://github.com/tlverse/delayed/actions)
[![Coverage Status](https://codecov.io/gh/tlverse/delayed/branch/master/graph/badge.svg)](https://codecov.io/gh/tlverse/delayed)
[![CRAN](http://www.r-pkg.org/badges/version/delayed)](http://www.r-pkg.org/pkg/delayed)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/delayed)](https://CRAN.R-project.org/package=delayed)
[![CRAN total downloads](http://cranlogs.r-pkg.org/badges/grand-total/origami)](https://CRAN.R-project.org/package=origami)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
> A framework for parallelizing dependent tasks
__Author:__ [Jeremy Coyle](https://github.com/jeremyrcoyle)
---
## What's `delayed`?
`delayed` is an R package that provides a framework for parallelizing dependent
tasks in an efficient manner. It brings to R a subset of the
functionality implemented in Python's [Dask
library](https://dask.pydata.org/en/latest/). For details on how best to use
`delayed`, please consult the package
[documentation](https://nhejazi.github.io/delayed/) and
[vignette](https://nhejazi.github.io/delayed/articles/delayed.html)
online, or do so from within [R](https://www.r-project.org/).
---
## Installation
For standard use, we recommend installing the package from
[CRAN](https://cran.r-project.org/) via
```{r cran-installation, eval = FALSE}
install.packages("delayed")
```
Install the most recent _stable release_ from GitHub via
[`devtools`](https://www.rstudio.com/products/rpackages/devtools/):
```{r gh-master-installation, eval = FALSE}
devtools::install_github("tlverse/delayed")
```
---
## Issues
If you encounter any bugs or have any specific feature requests, please [file an
issue](https://github.com/tlverse/delayed/issues).
---
## Example
This minimal example shows how to use `delayed` to handle dependent computations
via chaining of tasks:
```{r delay_fun_chain}
library(delayed)
# delay a function that does a bit of math
mapfun <- function(x, y) {(x + y) / (x - y)}
delayed_mapfun <- delayed_fun(mapfun)
set.seed(14765)
library(future)
plan(multicore, workers = 2)
const <- 7
# re-define the delayed object from above
delayed_norm <- delayed(rnorm(n = const))
delayed_pois <- delayed(rpois(n = const, lambda = const))
chained_norm_pois <- delayed_mapfun(delayed_norm, delayed_pois)
# compute it using the future plan (multicore with 2 cores)
chained_norm_pois$compute(nworkers = 2, verbose = TRUE)
```
_Remark:_ In the above, the delayed computation is carried out in parallel using
the framework offered by the excellent [`future`
package](https://github.com/HenrikBengtsson/future) and its associated
ecosystem.
---
## License
© 2017-2021 [Jeremy R. Coyle](https://github.com/jeremyrcoyle)
The contents of this repository are distributed under the GPL-3 license. See
file `LICENSE` for details.