Description Usage Arguments Value See Also Examples
Checks to see if the input is an integer.
1 2 3 4 5 6 7 | assert_is_an_integer(x, severity = getOption("assertive.severity", "stop"))
assert_is_integer(x, severity = getOption("assertive.severity", "stop"))
is_an_integer(x, .xname = get_name_in_parent(x))
is_integer(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_integer
wraps is.integer
, providing more
information on failure. is_an_integer
returns TRUE
if the
input is an integer and scalar. The assert_*
functions return
nothing but throw an error if the corresponding is_*
function
returns FALSE
.
is.integer
and is_scalar
.
1 2 3 4 5 6 | assert_is_integer(1:10)
assert_is_an_integer(99L)
#These examples should fail.
assertive.base::dont_stop(assert_is_integer(c(1, 2, 3)))
assertive.base::dont_stop(assert_is_an_integer(1:10))
assertive.base::dont_stop(assert_is_an_integer(integer()))
|
$`assert_is_integer(c(1, 2, 3))`
<assertionError: is_integer : c(1, 2, 3) is not of class 'integer'; it has class 'numeric'.>
$`assert_is_an_integer(1:10)`
<assertionError: is_an_integer : 1:10 has length 10, not 1.>
$`assert_is_an_integer(integer())`
<assertionError: is_an_integer : integer() has length 0, not 1.>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.