Learn R Programming

assertive (version 0.2-6)

assert_all_are_divisible_by: Is the input divisible by a number?

Description

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

Usage

assert_all_are_divisible_by(x, n, tol = 100 * .Machine$double.eps)

assert_any_are_divisible_by(x, n, tol = 100 * .Machine$double.eps)

assert_all_are_even(x, tol = 100 * .Machine$double.eps)

assert_any_are_even(x, tol = 100 * .Machine$double.eps)

assert_all_are_odd(x, n, tol = 100 * .Machine$double.eps)

assert_any_are_odd(x, n, tol = 100 * .Machine$double.eps)

assert_all_are_odd(x, n, tol = 100 * .Machine$double.eps)

assert_any_are_odd(x, n, tol = 100 * .Machine$double.eps)

is_divisible_by(x, n, tol = 100 * .Machine$double.eps)

is_even(x, tol = 100 * .Machine$double.eps)

is_odd(x, tol = 100 * .Machine$double.eps)

Arguments

x
A numeric vector to divide.
n
A numeric vector to divide by.
tol
Differences from zero smaller than tol are not considered.

Value

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

See Also

is_whole_number

Examples

Run this code
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)
dont_stop(assert_all_are_even(1:10))

Run the code above in your browser using DataLab