% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/whole.r
\name{is.whole}
\alias{is.whole}
\alias{is.wholenumber}
\alias{is.integerish}
\title{Are vectors whole or integer-like?}
\usage{
is.whole(x, tol = .Machine$double.eps^0.5)

is.wholenumber(x, tol = .Machine$double.eps^0.5)

is.integerish(x)
}
\arguments{
\item{x}{a logical, numeric, or complex vector.}

\item{tol}{numeric tolerance for wholeness.}
}
\value{
For \code{is.whole()} and \code{is.integerish()} a single \code{TRUE} or \code{FALSE}.

For \code{is.wholenumber()}, a logical vector of the same length as \code{x}.
}
\description{
Tests if numeric vectors are integerish, or whole according to a
given tolerance.

\code{is.whole()} and \code{is.integerish()} check if the entire vector
is whole or integerish, whilst \code{is.wholenumber()} checks element-wise
for wholeness.
}
\details{
\code{is.integerish()} tests if a vector is integerish by evaluating if the
remainder of the \link[=abs]{absolute} value of \code{x} divided by \code{1} is 'equal'
to \code{0.0} in the \code{C} code.

\code{is.whole()} and \code{is.wholenumber()} test for wholeness by evaluating
if the \link[=abs]{absolute} value of \code{x} minus its rounded value is less than
the given tolerance.

Both \code{is.integerish()} and \code{is.whole()} ignore non-finite values (i.e.,
treat them as integerish/whole) and only test finite values for
integerishness or wholeness. If you do not want this behavior, use
\link{anyNF}, e.g., \code{!anyNF(x) && is.whole(x)}.

\code{is.wholenumber()} returns \code{NA} for non-finite elements.
}
\examples{
is.integerish(1)
is.integerish(1.0)
is.integerish(1.0000000001)
is.integerish(1.0000000000000001)

is.wholenumber(1)
x <- c(1.0, 1.0000001, 1.0000000001)
is.wholenumber(x)
is.whole(x)


# ignores non-finite values:
is.integerish(c(Inf, -Inf, NaN, NA))
is.whole(c(Inf, -Inf, NaN, NA))

# non-finite values flag as NA:
is.wholenumber(c(Inf, -Inf, NaN, NA))

# all error on non-numeric vector inputs:
try(is.integerish("1"))
try(is.whole("1"))
try(is.wholenumber("1"))
}
\seealso{
\link{is.integerish}, \link{anyNF}
}
