tryNULL | R Documentation |
A convenient wrapper to capture errors in an expression
returning NULL
rather than error out.
This simplifies error catching for downstream functionality via
is.null()
. See try()
and tryCatch()
.
tryNULL(expr, default = NULL, quiet = TRUE)
expr |
An R expression to try. |
default |
The value to return if an error is encountered.
By default, and according to the function name, |
quiet |
Logical. Should the error message (if encountered) be printed? |
Either the value of the expression in expr
or,
if an error is encountered, the value in default
.
Stu Field
More or less "borrowed" from the plyr package.
try()
, tryCatch()
tryNULL(log("a")) tryNULL(log("a"), quiet = FALSE) tryNULL(log("a"), default = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.