DBDelve
Dive deep into your data. A fast, native, multi-engine database client written in Rust. Free and open source, no telemetry.
翻译准备中
Compares two tables value by value. A candidate table can be checked against a benchmark whose column types are taken as the truth, with the candidates columns cast to those types first, or two tables
翻译准备中
开发工具RGitHub @pedrobtz在线运营者未确认
试用过了吗? 点一下就好,无需登录。
尚未检测到更新。GitHub 发布版本后会显示在这里。
Compares two tables value by value. A candidate table can be checked against a benchmark whose column types are taken as the truth, with the candidates columns cast to those types first, or two tables can be checked for equality as peers. Rows are aligned on their identity columns, numeric measures are compared within an optional tolerance, and the result is a long data.table' with one row per compared value that traces back to the source rows of both inputs.
翻译准备中
正在加载完整 README。
查看完整 README ↗dazdiff compares two tables value by value. Its one main function,
diff_table(), answers one of two questions:
mode = "benchmark", the
default.) The benchmark's column types are the truth. The tested table's
columns are cast to them, and its extra columns are dropped.mode = "equal".) The tables are peers:
every column must be in both, with the same type, and nothing is cast.The result is a data.table with one row per compared value. Each row traces
back to its source row in both tables.
Install the released version from CRAN:
install.packages("dazdiff")
Or the development version from GitHub:
# install.packages("pak")
pak::pak("pedrobtz/dazdiff")
A benchmark table, and the same data after a round trip through storage. On
the way, the column names changed case, the ids became text, units came back
as a double, a load timestamp was added, one row was lost and one was added:
library(dazdiff)
benchmark <- data.frame(
id = c(1L, 2L, 3L, 4L),
region = c("north", "south", "east", "west"),
amount = c(100, 200, 300, 400),
units = c(10L, 20L, 30L, 40L)
)
stored <- data.frame(
ID = c("1", "2", "3", "5"),
Region = c("north", "south", "east", "north"),
Amount = c(100, 200.5, 300, 500),
Units = c(10.4, 20, 30, 50),
loaded_at = "2026-09-29"
)
d <- diff_table(benchmark, stored, by = c("id", "region"), measures = "numeric+integer")
#> Dropped column(s) of `y` that the benchmark `x` does not have: loaded_at.
#> Truncated 1 value(s) while casting to the reference types:
#> Units: 1 (10.4 -> 10)
d
#> Key: <ID, REGION, metric>
#> ID REGION metric row_id_x row_id_y value_x value_y diff abs_diff rel_diff status
#> <int> <char> <char> <int> <int> <num> <num> <num> <num> <num> <fctr>
#> 1: 1 north AMOUNT 1 1 100 100.0 0.0 0.0 0.000000000 same
#> 2: 1 north UNITS 1 1 10 10.0 0.0 0.0 0.000000000 same
#> 3: 2 south AMOUNT 2 2 200 200.5 0.5 0.5 0.002493766 changed
#> 4: 2 south UNITS 2 2 20 20.0 0.0 0.0 0.000000000 same
#> 5: 3 east AMOUNT 3 3 300 300.0 0.0 0.0 0.000000000 same
#> 6: 3 east UNITS 3 3 30 30.0 0.0 0.0 0.000000000 same
#> 7: 4 west AMOUNT 4 NA 400 NA NA NA NA only_x
#> 8: 4 west UNITS 4 NA 40 NA NA NA NA only_x
#> 9: 5 north AMOUNT NA 4 NA 500.0 NA NA NA only_y
#> 10: 5 north UNITS NA 4 NA 50.0 NA NA NA only_y
Reading the result:
status is same, changed, only_x (the row is missing from the
tested table) or only_y (the row exists only there).row_id_x and row_id_y are the row numbers in the two inputs.diff is value_y - value_x; abs_diff is its size, and
rel_diff the size relative to the larger of the two values._. That is why id and ID pair up.units was cast to the benchmark's integer type. Its 10.4 was
truncated to 10, which is announced in a message and recorded, with the
rows it touched, in attr(d, "truncated"). Pass truncate = FALSE to refuse such casts
instead.diff_summary() condenses the result per measure:
diff_summary(d)
#> metric n n_same n_changed n_only_x n_only_y max_abs_diff mean_abs_diff rmse max_rel_diff
#> <char> <int> <int> <int> <int> <int> <num> <num> <num> <num>
#> 1: AMOUNT 5 2 1 1 1 0.5 0.1666667 0.2886751 0.002493766
#> 2: UNITS 5 3 0 1 1 0.0 0.0000000 0.0000000 0.000000000
diff_report() draws the whole comparison as text: the columns compared, how
the rows of the two tables align, and how much each measure differs:
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗