These functions work exactly the same as map_vec(), map2_vec(), pmap_vec(), imap_vec() and xmap_vec(), but allow you to map in parallel.

future_map_vec(
  .x,
  .f,
  ...,
  .progress = FALSE,
  .options = furrr::future_options()
)

future_map2_vec(
  .x,
  .y,
  .f,
  ...,
  .progress = FALSE,
  .options = furrr::future_options()
)

future_pmap_vec(
  .l,
  .f,
  ...,
  .progress = FALSE,
  .options = furrr::future_options()
)

future_imap_vec(
  .x,
  .f,
  ...,
  .progress = FALSE,
  .options = furrr::future_options()
)

future_xmap_vec(
  .l,
  .f,
  ...,
  .progress = FALSE,
  .options = furrr::future_options()
)

Arguments

.x

A list or atomic vector.

.f

A function, formula, or vector (not necessarily atomic).

If a function, it is used as is.

If a formula, e.g. ~ .x + 2, it is converted to a function. There are three ways to refer to the arguments:

  • For a single argument function, use .

  • For a two argument function, use .x and .y

  • For more arguments, use ..1, ..2, ..3 etc

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 .default will be returned.

...

Additional arguments passed on to .f

.progress

A logical, for whether or not to print a progress bar for multiprocess, multisession, and multicore plans

.options

The future specific options to use with the workers. This must be the result from a call to furrr::future_options()

.y

A vector the same length as .x. Vectors of length 1 will be recycled.

.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.

Value

Equivalent to map_vec(), map2_vec(), pmap_vec(), imap_vec() and xmap_vec()

See also

Examples

fruits <- c("apple", "banana", "carrot", "durian", "eggplant") desserts <- c("bread", "cake", "cupcake", "streudel", "muffin") x <- sample(5) y <- sample(5) z <- sample(5) names(z) <- fruits future_map_vec(x, ~ . ^ 2)
#> Warning: No future plan is set, so `future_map_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] 25 9 16 1 4
future_map_vec(fruits, paste0, "s")
#> Warning: No future plan is set, so `future_map_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] "apples" "bananas" "carrots" "durians" "eggplants"
future_map2_vec(x, y, ~ .x + .y)
#> Warning: No future plan is set, so `future_map2_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] 9 5 5 4 7
future_map2_vec(fruits, desserts, paste)
#> Warning: No future plan is set, so `future_map2_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] "apple bread" "banana cake" "carrot cupcake" "durian streudel" #> [5] "eggplant muffin"
future_pmap_vec(list(x, y, z), sum)
#> Warning: No future plan is set, so `future_pmap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] 14 7 9 5 10
future_pmap_vec(list(x, fruits, desserts), paste)
#> Warning: No future plan is set, so `future_pmap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] "5 apple bread" "3 banana cake" "4 carrot cupcake" #> [4] "1 durian streudel" "2 eggplant muffin"
future_imap_vec(x, ~ .x + .y)
#> Warning: No future plan is set, so `future_imap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] 6 5 7 5 7
future_imap_vec(x, ~ paste0(.y, ": ", .x))
#> Warning: No future plan is set, so `future_imap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] "1: 5" "2: 3" "3: 4" "4: 1" "5: 2"
future_imap_vec(z, paste)
#> Warning: No future plan is set, so `future_imap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> apple banana carrot durian eggplant #> "5 apple" "2 banana" "4 carrot" "1 durian" "3 eggplant"
future_xmap_vec(list(x, y), ~ .x * .y)
#> Warning: No future plan is set, so `future_xmap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> Warning: No future plan is set, so `future_xmap()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] 20 12 16 4 8 10 6 8 2 4 5 3 4 1 2 15 9 12 3 6 25 15 20 5 10
future_xmap_vec(list(fruits, desserts), paste)
#> Warning: No future plan is set, so `future_xmap_vec()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> Warning: No future plan is set, so `future_xmap()` is not parallelized. #> * Try `future::plan("multiprocess")`
#> [1] "apple bread" "banana bread" "carrot bread" #> [4] "durian bread" "eggplant bread" "apple cake" #> [7] "banana cake" "carrot cake" "durian cake" #> [10] "eggplant cake" "apple cupcake" "banana cupcake" #> [13] "carrot cupcake" "durian cupcake" "eggplant cupcake" #> [16] "apple streudel" "banana streudel" "carrot streudel" #> [19] "durian streudel" "eggplant streudel" "apple muffin" #> [22] "banana muffin" "carrot muffin" "durian muffin" #> [25] "eggplant muffin"