The built-in function is.integer()
will check if a number is of
the integer
class. However, we would usually want a function
that can check if a number is a whole number. It is also
vectorised over the input.
is_wholenumber(x, tol = .Machine$double.eps^0.5)
x | Number to check |
---|---|
tol | tolerance to check the values |
A logical vector the same length as x
#> [1] FALSEis_wholenumber(2)#> [1] TRUE#> [1] FALSE#> [1] TRUE FALSE FALSE FALSE TRUE