future_xmap {crossmap} | R Documentation |
Map over each combination of list elements simultaneously via futures
Description
These functions work exactly the same as xmap()
functions,
but allow you to run the map in parallel using future::future()
Usage
future_xmap(.l, .f, ..., .progress = FALSE, .options = furrr::furrr_options())
future_xmap_chr(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_dbl(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_dfc(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_dfr(
.l,
.f,
...,
.id = NULL,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_int(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_lgl(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xmap_raw(
.l,
.f,
...,
.progress = FALSE,
.options = furrr::furrr_options()
)
future_xwalk(.l, .f, ..., .progress = FALSE, .options = furrr::furrr_options())
Arguments
.l |
A list of vectors, such as a data frame. The length of .l determines the number of arguments that .f will be called with. List names will be used if present. |
.f |
A function, formula, or vector (not necessarily atomic). If a function, it is used as is. If a formula, e.g.
This syntax allows you to create very compact anonymous functions. If character vector, numeric vector, or list, it is
converted to an extractor function. Character vectors index by
name and numeric vectors index by position; use a list to index
by position and name at different levels. If a component is not
present, the value of |
... |
Additional arguments passed on to |
.progress |
A single logical. Should a progress bar be displayed? Only works with multisession, multicore, and multiprocess futures. Note that if a multicore/multisession future falls back to sequential, then a progress bar will not be displayed. Warning: The |
.options |
The |
.id |
Either a string or Only applies to |
Value
An atomic vector, list, or data frame, depending on the suffix. Atomic vectors and lists will be named if the first element of .l is named.
If all input is length 0, the output will be length 0. If any input is length 1, it will be recycled to the length of the longest.
See Also
xmap()
to run functions without parallel processing.
future_xmap_vec()
to automatically determine output type.
future_xmap_mat()
and future_xmap_arr()
to return results in a matrix
or array.
furrr::future_map()
, furrr::future_map2()
, and furrr::future_pmap()
for other parallelized mapping functions.
Examples
future_xmap(list(1:5, 1:5), ~ .y * .x)
future_xmap_dbl(list(1:5, 1:5), ~ .y * .x)
future_xmap_chr(list(1:5, 1:5), ~ paste(.y, "*", .x, "=", .y * .x))
apples_and_bananas <- list(
x = c("apples", "bananas"),
pattern = "a",
replacement = c("oo", "ee")
)
future_xmap_chr(apples_and_bananas, gsub)
formulas <- list(mpg ~ wt, mpg ~ hp)
subsets <- split(mtcars, mtcars$cyl)
future_xmap(list(subsets, formulas), ~ lm(.y, data = .x))