stop_if | R Documentation |
If the `condition`
is TRUE
,
generate error
/warning
/message
with the supplied message.
stop_if(condition, message = NULL, sys.parent.n = 0L)
warn_if(condition, message = NULL, sys.parent.n = 0L)
message_if(condition, message = NULL, sys.parent.n = 0L)
condition |
The condition to check. (Logical) |
message |
Message. (Character) Note: If |
sys.parent.n |
The number of generations to go back when calling the message function. |
When `condition`
is FALSE
, they return NULL
invisibly.
When `condition`
is TRUE
:
Throws error with the supplied message.
Throws warning with the supplied message.
Generates message with the supplied message.
Returns NULL
invisibly.
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
# Attach packages
library(xpectr)
# Note: The use of `try()` is just for package-testing purposes
a <- 0
try(stop_if(a == 0, "'a' cannot be 0."))
try(warn_if(a == 0, "'a' was 0."))
message_if(a == 0, "'a' was so kind to be 0.")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.