Description Usage Arguments Details Value Examples

Apply a Function to a Data Frame Split by Factors via Futures

1 |

`data` |
An |

`INDICES` |
A factor or a list of factors, each of length |

`FUN` |
a function to be applied to (usually data-frame) subsets of |

`simplify` |
logical: see base::tapply. |

`...` |
Additional arguments pass to |

Internally, `data`

is grouped by `INDICES`

into a list of `data`

subset elements which is then processed by `future_lapply()`

.
When the groups differ significantly in size, the processing time
may differ significantly between the groups.
To correct for processing-time imbalances, adjust the amount of chunking
via arguments `future.scheduling`

and `future.chunk.size`

.

An object of class "by", giving the results for each subset.
This is always a list if simplify is false, otherwise a list
or array (see base::tapply).
See also `base::by()`

for details.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
## ---------------------------------------------------------
## by()
## ---------------------------------------------------------
library(datasets) ## warpbreaks
library(stats) ## lm()
y0 <- by(warpbreaks, warpbreaks[,"tension"],
function(x) lm(breaks ~ wool, data = x))
plan(multiprocess)
y1 <- future_by(warpbreaks, warpbreaks[,"tension"],
function(x) lm(breaks ~ wool, data = x))
plan(sequential)
y2 <- future_by(warpbreaks, warpbreaks[,"tension"],
function(x) lm(breaks ~ wool, data = x))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.