Description Usage Arguments Value References See Also Examples
Checks to see if the input is a closure, builtin or special function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | assert_is_closure_function(x, severity = getOption("assertive.severity",
"stop"))
assert_is_builtin_function(x, severity = getOption("assertive.severity",
"stop"))
assert_is_special_function(x, severity = getOption("assertive.severity",
"stop"))
is_closure_function(x, .xname = get_name_in_parent(x))
is_builtin_function(x, .xname = get_name_in_parent(x))
is_special_function(x, .xname = get_name_in_parent(x))
|
x |
Input to check. |
severity |
How severe should the consequences of the assertion be?
Either |
.xname |
Not intended to be used directly. |
is_internal_function
returns TRUE
when the input is a
closure function that calls .Internal
. The
assert_*
function returns nothing but throw an error if the
corresponding is_*
function returns FALSE
.
There is some discussion of closure vs. builtin vs. special functions in the Argument Evaluation section of R-internals. https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Argument-evaluation
is.function
and its assertive wrapper
is_function
.
typeof
is used to distinguish the three types
of function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # most functions are closures
is_closure_function(mean)
is_closure_function(lm)
is_closure_function(summary)
# builtin functions are typically math operators, low level math functions
# and commonly used functions
is_builtin_function(`*`)
is_builtin_function(cumsum)
is_builtin_function(is.numeric)
# special functions are mostly language features
is_special_function(`if`)
is_special_function(`return`)
is_special_function(`~`)
# some failure messages
assertive.base::dont_stop({
assert_is_builtin_function(mean)
assert_is_builtin_function("mean")
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.