# is.wholenumber: Is Object Numeric and Whole Numbers In DistributionUtils: Distribution Utilities

## Description

Checks whether an object is numeric and if so, are all the elements whole numbers, to a given tolerance.

## Usage

 `1` ```is.wholenumber(x, tolerance = .Machine\$double.eps^0.5) ```

## Arguments

 `x` The object to be tested. `tolerance` Numeric >=0. Absolute differences greater than `tolerance` are treated as real differences.

## Details

The object `x` is first tested to see if it is numeric. If not the function returns `'FALSE'`. Then if all the elements of `x` are whole numbers to within the tolerance given by `tolerance` the function returns `'TRUE'`. If not it returns `'FALSE'`.

## Value

Either `'TRUE'` or `'FALSE'` depending on the result of the test.

## Author(s)

David Scott [email protected].

## References

Based on a post by Tony Plate <[email protected]> on R-help.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```is.wholenumber(-3:5) # TRUE is.wholenumber(c(0,0.1,1.3,5)) # FALSE is.wholenumber(-3:5 + .Machine\$double.eps) # TRUE is.wholenumber(-3:5 + .Machine\$double.eps^0.5) # FALSE is.wholenumber(c(2L,3L)) # TRUE is.wholenumber(c("2L","3L")) # FALSE is.wholenumber(0i ^ (-3:3)) # FALSE is.wholenumber(matrix(1:6, nrow = 3)) # TRUE is.wholenumber(list(-1:3,2:6)) # FALSE is.numeric(list(-1:3,2:6)) # FALSE is.wholenumber(unlist(list(-1:3,2:6))) # TRUE ```

DistributionUtils documentation built on May 31, 2017, 4:18 a.m.