Learn R Programming

mikropml (version 1.6.1)

is_whole_number: Check whether a numeric vector contains whole numbers.

Description

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.

Usage

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

Value

logical vector

Arguments

x

numeric vector

tol

tolerance (default: .Machine$double.eps^0.5)

Examples

Run this code
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