Checks whether values are integer-like within a numerical tolerance. Works for numeric, integer, and complex vectors.
Usage
isWholeLike(
x,
all = TRUE,
isNonNegative = FALSE,
tol = sqrt(.Machine$double.eps),
na.rm = FALSE
)Arguments
- x
a numeric, integer, or complex vector.
- all
logical. If
TRUE(default), returns a single logical indicating whether all elements are whole-like. IfFALSE, returns a logical vector of the same length asx.- isNonNegative
logical. If
TRUE, additionally requires values to be non-negative.- tol
numerical tolerance for comparing to the nearest integer. Default is
sqrt(.Machine$double.eps).- na.rm
logical. If
TRUE, missing values are removed before testing. IfFALSE(default) andxcontainsNA, the result isFALSE.
Details
A value is considered whole-like if the absolute difference between
the value and its nearest integer is smaller than tol.
For complex numbers, both real and imaginary parts must be whole-like;
with isNonNegative = TRUE, both parts must additionally be
non-negative.
See also
Other data.predicate:
flags(),
isDichotomous(),
isEuclid(),
isLowCardinality(),
isNumeric(),
isZero(),
nUnique()
