powered by
Modify a function so that it returns a default value when there is an error.
failwith(default = NULL, f, quiet = FALSE)
default value
function
all error messages be suppressed?
a function
try_default
# NOT RUN { f <- function(x) if (x == 1) stop("Error!") else 1 # } # NOT RUN { f(1) f(2) # } # NOT RUN { safef <- failwith(NULL, f) safef(1) safef(2) # }
Run the code above in your browser using DataLab