Detect whether two objects differ, with special handling for data frames
Source:R/dl_detect_change.R
dl_detect_change.RdThis function compares old and new objects to determine whether
they have changed. It ignores the .created_at attribute for all object
types. For data frames, the function reports the difference in row counts
and column counts (for example, "changed: +10 rows, -2 columns"). For all
other object types, the function returns either "unchanged" or "changed".
Details
Possible return values:
"unchanged": the objects are identical after ignoring
.created_at"changed": the objects differ (non–data-frame objects)
"changed: +X rows, +Y columns": the data frame gained rows/columns
"changed: -X rows, -Y columns": the data frame lost rows/columns
"changed: +0 rows, +0 columns": dimensions match but contents differ
Examples
old <- data.frame(a = 1:10)
new <- data.frame(a = 1:15, b = 1:15)
dl_detect_change(old, new)
#> [1] "changed: +5 rows, +1 cols"
# "changed: +5 rows, +1 columns"