IsWhole.Rd
Test if x contains only integer numbers, or if is numeric or if it is zero.
a (non-empty) numeric vector of data values.
logical, specifying if the whole vector should be checked. If set to TRUE
the function will
return the result of all(IsWhole(x))
.
tolerance to be used
integer, the length of the vector to be checked for.
logical, should x be checked as integer?
logical, is x supposed to be positive?
logical, indicating whether NA
values should be stripped before the computation proceeds. Defaults to FALSE
.
IsWhole is the suggested solution for checking for an integer value, as is.integer
tests for class(x) == "integer"
and does NOT test whether x (which might be of class "numeric") contains only integer numbers.
(Why not simply implement it in base?)
IsZero tests float numeric values for being zero.
IsNumeric combines a test for numeric and integers.
logical vector of the same dimension as x.
(x <- seq(1,5, by=0.5))
#> [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
IsWhole( x ) #--> \code{TRUE} \code{FALSE} \code{TRUE} ...
#> [1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE
# ... These are people who live in ignorance of the Floating Point Gods.
# These pagans expect ... (Burns, 2011)" the following to be TRUE:
(.1 - .3 / 3) == 0
#> [1] FALSE
# they might be helped by
IsZero(.1 - .3 / 3)
#> [1] TRUE