First release.
diff_table() compares two tables value by value, returning a
data.table with one row per compared value, traceable to its source row
in both inputs (row_id_x, row_id_y), and a status of same,
changed, only_x or only_y.mode = "benchmark" (the default) tests y against the benchmark x.
y's columns are cast to x's types, its extra columns are dropped
with a message, and a column it lacks is an error.mode = "equal" compares the two as peers. Every column must be in
both tables with the same type, nothing is cast, and the result is
symmetric.exclude leaves columns out of the comparison, in either mode: they are
removed from both tables, in either spelling, before anything else. A name
in neither table is a warning, so one list of technical columns can serve
many tables.y cast to the benchmark's text is written with the decimals
the benchmark uses, when they are the same for the whole column, so 2
meets "2.0", and a message says so (dazdiff_message_cast_format). A
number that still matches only by value, not by text, is a warning
(dazdiff_warning_cast_format) that explains the format used.exclude for those holding
one value in each table.truncate = FALSE refuses
them."%Y-%m-%d %H:%M:%S", midnight
included, with its fraction of a second (to the microsecond) when it has
one, so the text does not depend on the values or the R version.NA, which is how read.csv() and
fread() type a column with no values, casts to any type, a Date
included._, so amount and Amount are one column. Letters outside ASCII are
kept. Two names in one table that normalize to the same thing are an
error.by names the row identity. measures chooses the compared columns, by
type ("numeric", "numeric+integer") or by name. With no measures,
diff_table() compares whole rows.row_key = "position" adds the row number as a virtual key, and
row_key = "sorted" adds it after sorting both tables by their values, so
row order does not matter.duplicates = "aggregate", or refused with
duplicates = "error".nan_is_na = TRUE treats NaN as NA, in values and in key columns alike.rel_tol adds a relative tolerance to the absolute tolerance: a value
is same when it is within either. The relative difference is taken
against the larger magnitude of the two values, so it is symmetric, and
both tolerances apply to finite pairs only. The result carries
abs_diff and rel_diff beside diff, diff_summary() reports
max_rel_diff, and the tolerances are recorded in attr(, "tolerance").diff_report() draws a bounded text report of a comparison: the columns
compared, a picture of how the rows of the two tables align, and per
measure its match rate and largest differences. The layout follows the summary of the Python package diffly.diff_explain() says which key values split the result into same and not
same: per key column (and per measure), how many of its values only match,
only differ or are mixed, and, for one column, the status counts of each
value. among = "joined" explains the changed values alone.is_matching() answers TRUE or FALSE: do the two tables match? With
tolerance or rel_tol it re-judges the stored differences at other
thresholds, looser or stricter, without running the comparison again.diff_summary() counts each status per measure and measures the size of
the differences.expect_table_equal() is a testthat expectation built on diff_table().
It allows a relative difference of sqrt(.Machine$double.eps) by default,
as testthat's expect_equal() does, where diff_table() is exact.
Duplicate keys are an error unless duplicates accepts them, and tables
that share no key fail the expectation.compare_columns() shows how the columns of two tables line up,
normalize_dt() converts other types (factors, timestamps, integer64)
to the ones diff_table() compares, and cast_rules() lists the
conversions it makes. A factor becomes its labels by default, and the
mappings given in normalize_dt(to = ) are added to that default.?diff_table.