powered by
Similar to try but also returns warnings.
try
tryWithWarnings(expr)
the line of code to be evaluated
A list containing:
value the result of the evaluation of the expression
warnings warning(s) generated during the evaluation of the expression
error error generated during the evaluation of the expression
from https://stackoverflow.com/questions/4948361/how-do-i-save-warnings-and-errors-as-output-from-a-function
# NOT RUN { FctTest <- function(x){ return(log(x)) } tryWithWarnings(FctTest(-1)) tryWithWarnings(FctTest(1)) tryWithWarnings(FctTest(xxxx)) # }
Run the code above in your browser using DataLab