\Header{all.equal}{Test if Two Objects are (Nearly) Equal}
\methalias{all.equal.character}{all.equal}
\methalias{all.equal.default}{all.equal}
\methalias{all.equal.factor}{all.equal}
\methalias{all.equal.formula}{all.equal}
\methalias{all.equal.language}{all.equal}
\methalias{all.equal.list}{all.equal}
\methalias{all.equal.numeric}{all.equal}
\alias{attr.all.equal}{all.equal}
\keyword{utilities}{all.equal}
\keyword{logic}{all.equal}
\keyword{arith}{all.equal}
\begin{Description}\relax
\code{all.equal(x,y)} is a utility to compare \R{} objects \code{x}
and \code{y} testing ``near equality''.  If they are different,
comparison is still made to some extent, and a report of the
differences is returned.\end{Description}
\begin{Usage}
\begin{verbatim}
all.equal(target, current, ...)

all.equal.numeric(target, current,
                  tolerance= .Machine$double.eps ^ 0.5, scale=NULL)
\end{verbatim}
\end{Usage}
\begin{Details}\relax
There are several methods available, most of which are dispatched by
the default method, see \code{\Link{methods}("all.equal")}.
\code{all.equal.list} and \code{all.equal.language} provide
comparison of recursive objects.

Numerical comparison is done using averge (\code{\Link{mean}})
\emph{relative} error, unless \code{scale} is used or when the
absolute difference is less than \code{tolerance}.
For complex arguments, \code{\Link{Mod}} of difference is used.

\code{attr.all.equal} is used for comparing
\code{\Link{attributes}}, returning \code{NULL} or \code{character}.\end{Details}
\begin{Value}
Either \code{TRUE} or a vector of \code{\Link{mode}}
\code{"character"} describing the differences between \code{target}
and \code{current}.

Numerical differences are reported by relative error\end{Value}
\begin{SeeAlso}\relax
\code{\Link{==}}, and \code{\Link{all}} for exact equality testing.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
all.equal(pi, 355/113) # not precise enough (default tol) > relative error

stopifnot(
all.equal(gamma(2:14),   cumprod(1:13))) # TRUE, but

all      (gamma(2:14) == cumprod(1:13)) # FALSE, since not exactly
all.equal(gamma(2:14),   cumprod(1:13), tol=0) # to see difference

all.equal(options(), .Options)
all.equal(options(), as.list(.Options))# TRUE
.Options $ myopt <- TRUE
all.equal(options(), as.list(.Options))
rm(.Options)
\end{ExampleCode}
\end{Examples}

