all.equal
is a generic function, dispatching methods on the
target
argument. To see the available methods, use
methods("all.equal")
, but note that the default method
also does some dispatching, e.g.using the raw method for logical
targets.
Remember that arguments which follow …
must be specified by
(unabbreviated) name. It is inadvisable to pass unnamed arguments in
…
as these will match different arguments in different
methods.
Numerical comparisons for scale = NULL
(the default) are
typically on relative difference scale unless the target values
are close to zero: First, the mean absolute difference of the two
numerical vectors is computed. If this is smaller than
tolerance
or not finite, absolute differences are used,
otherwise relative differences scaled by the mean absolute
target
value.
(Note that these comparisons are computed only for those vector elements
where target
is not NA
and differs from current
.)
If scale
is positive, absolute comparisons are made after
scaling (dividing) by scale
.
For complex target
, the modulus (Mod
) of the
difference is used: all.equal.numeric
is called so arguments
tolerance
and scale
are available.
The list
method compares components of
target
and current
recursively, passing all other
arguments, as long as both are “list-like”, i.e., fulfill
either is.vector
or is.list
.
The environment
method works via the list
method,
and is also used for reference classes (unless a specific
all.equal
method is defined).
The methods for the date-time classes by default allow a tolerance of
tolerance = 0.001
seconds, and ignore scale
.
attr.all.equal
is used for comparing
attributes
, returning NULL
or a
character
vector.