tryIt | R Documentation |
Evaluates an expression and returns NULL if it fails, instead of throwing an error.
tryIt(x, silent = TRUE)
x |
An R expression to evaluate |
silent |
Logical; if TRUE suppresses error messages (default FALSE) |
This function is useful for safely evaluating expressions that might fail, particularly in loops or apply functions where you want to continue execution even if some operations fail.
Returns the result of evaluating the expression if successful, NULL if it fails
# Successful evaluation
tryIt(1 + 1)
# Failed evaluation returns NULL
tryIt(log("a"))
# Suppress error messages
tryIt(log("a"), silent=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.