Compare the values of two objects to check whether they are equal
Source:R/gradethis_equal.R
gradethis_equal.Rd
Compare the values of two objects to check whether they are equal
Arguments
- x, y
Two objects to compare
- ...
Additional arguments passed to methods
- tolerance
If non-
NULL
, used as threshold for ignoring small floating point difference when comparing numeric vectors. Using any non-NULL
value will cause integer and double vectors to be compared based on their values, not their types, and will ignore the difference betweenNaN
andNA_real_
.It uses the same algorithm as
all.equal()
, i.e., first we generatex_diff
andy_diff
by subsettingx
andy
to look only locations with differences. Then we check thatmean(abs(x_diff - y_diff)) / mean(abs(y_diff))
(or justmean(abs(x_diff - y_diff))
ify_diff
is small) is less thantolerance
.
Value
A logical value of length one, or an internal gradethis error.
Methods (by class)
gradethis_equal(default)
: The default comparison method, which uses waldo::comparegradethis_equal(list)
: The comparison method for lists