purrr icon indicating copy to clipboard operation
purrr copied to clipboard

Please clarify `possibly()` documentation

Open phargarten2 opened this issue 2 years ago • 0 comments

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!

phargarten2 avatar May 25 '22 17:05 phargarten2