View source: R/compare_datasets.R
| get_all_differences | R Documentation |
Converts per-variable observation differences into a single long-format
data frame suitable for filtering with dplyr, writing to CSV, or
programmatic analysis. This is the R equivalent of SAS PROC COMPARE's
OUT= dataset with _TYPE_ and _DIF_ variables.
Accepts output from compare_datasets(), cdisc_compare(), or any list
containing an observation_comparison element with the standard
discrepancies / details / id_details structure.
get_all_differences(comparison_results)
comparison_results |
A |
A data frame with one row per differing cell. Columns:
Character: column name where the difference was found.
Integer: row index in df1 (positional matching).
The value in df1 (base dataset).
The value in df2 (compare dataset).
Numeric: Base - Compare (NA for character columns).
Numeric: absolute percentage difference relative to Base (NA when Base is 0 or column is character).
When key-based matching was used (id_vars), the ID columns are prepended to the left of the data frame.
Returns an empty data frame with the expected columns when no differences exist or observation comparison was skipped.
df1 <- data.frame(id = 1:3, value = c(10, 20, 30), name = c("A", "B", "C"))
df2 <- data.frame(id = 1:3, value = c(10, 25, 30), name = c("A", "B", "D"))
result <- compare_datasets(df1, df2)
diffs <- get_all_differences(result)
head(diffs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.