is_wholenumber()usesbase::round()to test whetherxis a whole number, it will therefore issue an error ifxis not of mode numeric. If used inbase::stopifnot()for example, this won't be a problem but it may be in conditionals.is_scalar_wholenumber()comes with the additional argumentcheck_numericto check whetherxis a numeric before checking it is a whole number.
Usage
is_wholenumber(x, tol = .Machine$double.eps^0.5)
is_scalar_wholenumber(x, check_numeric = TRUE, ...)Examples
is_wholenumber(1) # TRUE
#> [1] TRUE
is_wholenumber(1.0) # TRUE
#> [1] TRUE
is_wholenumber(1.1) # FALSE
#> [1] FALSE
is_scalar_wholenumber(1) # TRUE
#> [1] TRUE
is_scalar_wholenumber(c(1, 2)) # FALSE
#> [1] FALSE