Custom handling of errors and warnings in R function calls
04 Jul 2017
Let’s consider the following function in R, and assume we want to catch its
erros and warnings for later processing:
It’s pretty simple to catch the errors, or warnings:
Also, if we want to process errors and warnings the tryCatch() block
only processes the warning:
If we want it to handle warnings and errors equally, as well as still the the
function result when no error occurred, we need a more complicated construct:
Each of these calls returns a list with the elements result for the result of
the function call, but also warnings and error if they occurred.