Description Usage Arguments Value Note See Also Examples
Checks to see if the input is divisible by some number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | assert_all_are_divisible_by(x, n, tol = 100 * .Machine$double.eps,
na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
assert_any_are_divisible_by(x, n, tol = 100 * .Machine$double.eps,
na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
assert_all_are_even(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_any_are_even(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_all_are_odd(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_any_are_odd(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
is_divisible_by(x, n, tol = 100 * .Machine$double.eps,
.xname = get_name_in_parent(x))
is_even(x, tol = 100 * .Machine$double.eps, .xname = get_name_in_parent(x))
is_odd(x, tol = 100 * .Machine$double.eps, .xname = get_name_in_parent(x))
|
x |
A numeric vector to divide. |
n |
A numeric vector to divide by. |
tol |
Differences from zero smaller than |
na_ignore |
A logical value. If |
severity |
How severe should the consequences of the assertion be?
Either |
.xname |
Not intended to be used directly. |
TRUE
if the input x
is divisible by n
, within
the specified tolerance.
is_even
and is_odd
are shortcuts for divisibility by two.
1 2 3 4 5 | is_divisible_by(1:10, 3)
is_divisible_by(-5:5, -2)
is_divisible_by(1.5:10.5, c(1.5, 3.5))
assert_any_are_even(1:10)
assertive.base::dont_stop(assert_all_are_even(1:10))
|
There were 7 failures:
Position Value Cause
1 1 1 indivisible
2 2 2 indivisible
3 4 4 indivisible
4 5 5 indivisible
5 7 7 indivisible
6 8 8 indivisible
7 10 10 indivisible
There were 6 failures:
Position Value Cause
1 1 -5 indivisible
2 3 -3 indivisible
3 5 -1 indivisible
4 7 1 indivisible
5 9 3 indivisible
6 11 5 indivisible
There were 7 failures:
Position Value Cause
1 2 2.5 indivisible
2 3 3.5 indivisible
3 4 4.5 indivisible
4 5 5.5 indivisible
5 6 6.5 indivisible
6 8 8.5 indivisible
7 9 9.5 indivisible
$`assert_all_are_even(1:10)`
<assertionError: is_even : 1:10 are not all even (tol = 2.22045e-14).
There were 5 failures:
Position Value Cause
1 1 1 indivisible
2 3 3 indivisible
3 5 5 indivisible
4 7 7 indivisible
5 9 9 indivisible>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.