walk_functions: Supply each element in a vector to a function and collect the...

future_walkR Documentation

Supply each element in a vector to a function and collect the messages, warnings, and errors

Description

Think of these functions as the walk analogues to furrr's future_map functions. However, unlike purrr::walk and its ilk, these functions will not return the same value, but will return a list of named lists, where each named list contains a sublist of messages, warnings, and errors that arose during the execution of the function.

These functions are basically designed to be used when instead of returning data remotely, you want to save it somewhere. The (relatively) light-weight list they'll return will help you diagnose what went wrong, etc.

Usage

future_walk(.x, .f, ..., .progress = FALSE,
  .options = future_options())

future_walk2(.x, .y, .f, ..., .progress = FALSE,
  .options = future_options())

future_iwalk(.x, .f, ..., .progress = FALSE,
  .options = future_options())

future_pwalk(.l, .f, ..., .progress = FALSE,
  .options = future_options())

Arguments

.x

A list or atomic vector.

.f

A function, formula, or atomic vector.

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. Within a list, wrap strings in get-attr() to extract named attributes. 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 future_options().

.y

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

.l

A list of lists. The length of .l determines the number of arguments that .f will be called with. List names will be used if present.

Details

Underlyingly, these functions call the furrr future_map functions, but take the .f argument and essentially edit it, squeezing in a zplyr::collect_all wrapper while removing the $value element (this was done because accidentally returning huge models would slow down the parallelization considerably).

See Also

collected_info_to_df, future_map_maker


burchill/cs documentation built on May 28, 2023, 1:29 p.m.