| all.equal.mixtime::mt_time | R Documentation |
vecvec::class_vecvec's all.equal() method (which mixtime inherits,
since a mixtime vector is a vecvec) handles length/NA mismatches and
groups elements by their underlying storage slot, then compares each
group's raw values with all.equal(). That raw comparison has no notion
of chronon: two elements that are == (e.g. days(1) and hours(24), or
a yearmonth and an equivalent-instant yearweek) can end up stored with
different chronons or magnitudes, and so are wrongly reported as unequal.
This method fixes that at the per-slot level: elements already == (which
is chronon-aware, see mt_linear-compare/mt_duration-compare) count as
equal outright; for the rest, the discrepancy is measured as the duration
between them in their common chronon. A time point has no "typical
magnitude" to scale a relative tolerance against the way a plain number
does, so - unlike base::all.equal.numeric() - tolerance is always
absolute, in (possibly fractional) chronon units.
## S3 method for class ''mixtime::mt_time''
all.equal(target, current, tolerance = sqrt(.Machine$double.eps), ...)
target, current |
|
tolerance |
Numeric tolerance, as an absolute number of |
... |
Ignored. |
TRUE if target and current are equal within tolerance,
otherwise a string describing the discrepancy.
all.equal(yearmonth(0), yearmonth(0))
all.equal(yearmonth(0), yearmonth(1))
all.equal(days(1), hours(24))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.