failwith | R Documentation |
Modify a function so that it returns a default value when there is an error.
failwith(default = NULL, f, quiet = FALSE)
default |
default value |
f |
function |
quiet |
all error messages be suppressed? |
a function
try_default
f <- function(x) if (x == 1) stop("Error!") else 1
## Not run:
f(1)
f(2)
## End(Not run)
safef <- failwith(NULL, f)
safef(1)
safef(2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.