throw | R Documentation |
Generate and signal a condition.
throw(general, specifics = NULL, env = NULL, as = "error", class = NULL, ...)
general |
A single character which gives a general statement of the condition. |
specifics |
Optional. A character vector which gives a list of details
of the condition. If is |
env |
Optional. An environment or named list which is used to evaluate
the R code in the above arguments. See |
as |
Optional. |
class |
Optional. A character vector which assigns classes to the condition. |
... |
Optional. Additional arguments which are stored in the
condition and can be retrieved with |
If specifics
is character(0)
, returns an invisible NULL
.
Or signals an error, a warning, or a message.
general <- "You are wrong."
# returns silently
throw(general, character(0))
## Not run:
throw(general)
specifics <- c("Detail 1.", i = "Detail 2.")
throw(general, specifics)
# embed R code with glue syntax
throw("`x` is {x}.", env = list(x = 1))
## End(Not run)
# add and retrieve additional argument
tryCatch(
{ throw(general, arg = "I'm an additional argument.") },
error = function(e) e$arg
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.