powered by
Because is.integer checks for the class, not whether the number is an integer in the mathematical sense. This code was copy-pasted from the is.integer docs.
is.integer
is_whole_number(x, tol = .Machine$double.eps^0.5)
logical vector
numeric vector
tolerance (default: .Machine$double.eps^0.5)
.Machine$double.eps^0.5
if (FALSE) { is_whole_number(c(1, 2, 3)) is.integer(c(1, 2, 3)) is_whole_number(c(1.0, 2.0, 3.0)) is_whole_number(1.2) }
Run the code above in your browser using DataLab