| arg_formula | R Documentation |
Checks whether an argument is a formula.
arg_formula(
x,
one_sided = NULL,
.arg = rlang::caller_arg(x),
.msg = NULL,
.call
)
x |
the argument to be checked |
one_sided |
|
.arg |
the name of the argument supplied to |
.msg |
an optional alternative message to display if an error is thrown instead of the default message. |
.call |
the execution environment of a currently running function, e.g. |
Returns NULL invisibly if an error is not thrown.
rlang::is_formula(), arg_is()
form1 <- ~a + b
form2 <- y ~ a + b
not_form <- 1:3
try(arg_formula(form1)) # No error
try(arg_formula(form2)) # No error
try(arg_formula(not_form)) # Error: not a formula
try(arg_formula(form1,
one_sided = TRUE)) # No error
try(arg_formula(form2,
one_sided = TRUE)) # Error, not one-sided
try(arg_formula(form1,
one_sided = FALSE)) # Error, only one-sided
try(arg_formula(form2,
one_sided = FALSE)) # No error
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.