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

Description Usage Arguments Value Examples

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

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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))

bazar documentation built on May 2, 2019, 7:02 a.m.