Description Usage Arguments Value Author(s) Examples
Checks if an argument is an integer scalar
1 | assert_integer_scalar(arg, subset = "none", optional = FALSE)
|
arg |
A function argument to be checked |
subset |
A subset of integers that |
optional |
Is the checked parameter optional? If set to |
The function throws an error if arg
is not an integer belonging to the
specified subset
.
Thomas Neitmann
1 2 3 4 5 6 7 8 9 10 11 12 | example_fun <- function(num1, num2) {
assert_integer_scalar(num1, subset = "positive")
assert_integer_scalar(num2, subset = "negative")
}
example_fun(1, -9)
try(example_fun(1.5, -9))
try(example_fun(2, 0))
try(example_fun("2", 0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.