purrr
purrr copied to clipboard
Please clarify `possibly()` documentation
Greetings! Thank you for allowing an easier way to catch errors from functions using possibly()
.
However, the function is a bit unclear to me in what it returns (under "Value" )
Value
safely: wrapped function instead returns a list with components result and error. If an error occurred, error is an error object and result has a default value (otherwise). Else error is NULL.
quietly: wrapped function instead returns a list with components result, output, messages and warnings.
possibly: wrapped function uses a default value (otherwise) whenever an error occurs.
What precisely is a "wrapped function"? I had trouble using it, and I found two stack-overflow posts that describe how to correctly use possibly()
correctly.
https://stackoverflow.com/questions/50486527/how-to-use-map-with-possibly https://stackoverflow.com/questions/72365327/using-purrrpossibly-to-catch-non-positive-definite-matrix/72365359#72365359
Something like:
possibly()
takes a function .f
as input and exports it as a function, say possibly.f()
. Any arguments that are passed to possibly.f()
are passed to the function, .f
.
Thanks!