powered by
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.integer()
integer
is_wholenumber(x, tol = .Machine$double.eps^0.5)
Number to check
tolerance to check the values
A logical vector the same length as x
x
# NOT RUN { is.integer(2) is_wholenumber(2) is.integer(seq(2, 3, 0.25)) is_wholenumber(seq(2, 3, 0.25)) # }
Run the code above in your browser using DataLab