assert_all_are_divisible_by

0th

Percentile

Is the input divisible by a number?

Checks to see if the input is divisible by some number.

Usage
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))
Arguments
x
A numeric vector to divide.
n
A numeric vector to divide by.
tol
Differences from zero smaller than tol are not considered.
na_ignore
A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.
severity
How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".
.xname
Not intended to be used directly.
Value

TRUE if the input x is divisible by n, within the specified tolerance.

Note

is_even and is_odd are shortcuts for divisibility by two.

See Also

is_whole_number

Aliases
  • assert_all_are_divisible_by
  • assert_all_are_even
  • assert_all_are_odd
  • assert_any_are_divisible_by
  • assert_any_are_even
  • assert_any_are_odd
  • is_divisible_by
  • is_even
  • is_odd
Examples
library(assertive.numbers) 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))
Documentation reproduced from package assertive.numbers, version 0.0-2, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.