is_wholenumber: Test if the values of a vector are whole numbers

Description Usage Arguments Value Examples

View source: R/is_wholenumber.R

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
4
5
6
7
is_wholenumber(x, tolerance = sqrt(.Machine$double.eps))

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

as_wholenumber(x, ...)

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))

paulponcet/bazar documentation built on July 15, 2019, 5:28 a.m.