Description Usage Arguments Details Value Examples
This function is similar to purrr::pmap()
except that instead of stopping at the first
error it captures them and continues. If there are any errors it collects them together
and displays them at the end. You have the option to specify a prefix to the error message
using the msg_prefix
argument.
1 2 3 4 5 6 7 8 9 10 11 |
l |
(list) A list of vectors the same length to apply the function to. |
f |
(function) The function to map to the elements of the vectors in |
... |
(optional) Extra arguments to supply to f. |
msg_prefix |
(string, optional) A message to prefix any resulting error message. |
warn_level |
(integer, optional) The level of any warnings about errors encountered. If 0 then no warnings are shown. Default: 2. |
error_level |
(integer, optional) The level of any resulting errors. Default: 1. |
on_error |
(string) The kind of message to produce if there is an error. Either "info", "warn", or "error". Default: "error". |
simplify |
(boolean, optional) Whether to try to simplify the result of the mapping into an atomic vector. Default: FALSE. |
use_names |
(boolean, optional) Whether to use 'x' as names in the resulting list. 'x' must be a character vector for this to work. Default: TRUE. |
If the mapped function is a long running process try_pmap
can output a warning at the time
an error occurs, but specifying the warn_level
argument to be greater than 0 (see
warn()
for more details about message levels. Similarly error_level
argument specifies
the level of any reported error, as detailed in error()
.
If you do not want the function to stop with an error, you can instead return a warning or
info message using the on_error
argument.
Finally, simplify
and use_names
allow the user to specify whether to simplify the output
to an atomic vector, if possible, and whether to use the vector input x
as names to the
resulting list.
If simplify = FALSE
a list is returned. Otherwise, the function attempts to
simplify the result to an atomic vector.
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.