Learn R Programming

bazar (version 1.0.11)

is.wholenumber: Test if the values of a vector are whole numbers

Description

The function is.wholenumber tests if values of the numeric vector x are all whole numbers (up to a tolerance).

The function as.wholenumber is a synonym for as.integer.

Usage

is.wholenumber(x, tolerance = sqrt(.Machine$double.eps))

as.wholenumber(x, ...)

Arguments

x

a vector to be tested.

tolerance

numeric. Differences smaller than tolerance are considered as equal. The default value is close to 1.5e-8.

...

Additional arguments passed to or from other methods.

Value

A logical, TRUE if all values of x are (finite) whole numbers. If x contains NA or NaN, then NA is returned.

Examples

Run this code
# NOT RUN {
x = c(1L, 10L)
is.integer(x)
is.wholenumber(x)

x = c(1, 10)
is.integer(x)
is.wholenumber(x) # here is the difference with 'is.integer'

is.wholenumber(1+10^(-7))
is.wholenumber(1+10^(-8))

# }

Run the code above in your browser using DataLab