is_integer tests if x contains only integer numbers.

is_integer(x, tol = .Machine$double.eps^0.5)

Arguments

x

Number(s) to test (required, accepts numeric vectors).

tol

Numeric tolerance value. Default: tol = .Machine$double.eps^0.5 (see ?.Machine for details).

Details

Thus, is_integer does what the base R function is.integer is not designed to do:

  • is_integer() returns TRUE or FALSE depending on whether its numeric argument x is an integer value (i.e., a "whole" number).

  • is.integer() returns TRUE or FALSE depending on whether its argument is of type "integer", and FALSE if its argument is a factor.

See the documentation of is.integer for definition and details.

See also

is.integer function of the R base package.

Other verification functions: is_complement(), is_extreme_prob_set(), is_freq(), is_matrix(), is_perc(), is_prob(), is_suff_prob_set(), is_valid_prob_pair(), is_valid_prob_set(), is_valid_prob_triple()

Examples

is_integer(2)    # TRUE
#> [1] TRUE
is_integer(2/1)  # TRUE
#> [1] TRUE
is_integer(2/3)  # FALSE
#> [1] FALSE
x <- seq(1, 2, by = 0.5)
is_integer(x)
#> [1]  TRUE FALSE  TRUE

# Note contrast to base R:
is.integer(2/1)  # FALSE!
#> [1] FALSE

# Compare:
is.integer(1 + 2)
#> [1] FALSE
is_integer(1 + 2)
#> [1] TRUE