assert_all_numbers_are_whole_numbers

0th

Percentile

Is the input a whole number?

Checks that the (probably floating point) input is a whole number.

Usage
assert_all_numbers_are_whole_numbers(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
assert_any_numbers_are_whole_numbers(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
assert_all_are_whole_numbers(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
assert_any_are_whole_numbers(x, tol = 100 * .Machine$double.eps, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))
is_whole_number(x, tol = 100 * .Machine$double.eps, .xname = get_name_in_parent(x))
Arguments
x
Input to check.
tol
Differences 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 is a whole number.

Note

The term whole number is used to distinguish from integer in that the input x need not have type integer. In fact it is expected that x will be numeric.

See Also

is_divisible_by

Aliases
  • assert_all_are_whole_numbers
  • assert_all_numbers_are_whole_numbers
  • assert_any_are_whole_numbers
  • assert_any_numbers_are_whole_numbers
  • is_whole_number
Examples
library(assertive.numbers) # 1, plus or minus a very small number x <- 1 + c(0, .Machine$double.eps, -.Machine$double.neg.eps) # By default, you get a bit of tolerance for rounding errors is_whole_number(x) # Set the tolerance to zero for exact matching. is_whole_number(x, tol = 0)
Documentation reproduced from package assertive.numbers, version 0.0-2, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.