Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

comparedf

Compare two data.frames and report differences


Description

Compare two data.frames and report any differences between them, much like SAS's PROC COMPARE procedure.

Usage

comparedf(x, y, by = NULL, by.x = by, by.y = by, control = NULL, ...)

## S3 method for class 'comparedf'
print(x, ...)

Arguments

x, y

A data.frame to compare

by, by.x, by.y

Which variables are IDs to merge the two data.frames? If set to "row.names", merging will occur over the row.names. If set to NULL (default), merging will occur row-by-row.

control

A list of control parameters from comparedf.control.

...

Other arguments, passed to comparedf.control when appropriate.

Author(s)

Ethan Heinzen, adapted from code from Andrew Hanson

See Also

Examples

df1 <- data.frame(id = paste0("person", 1:3), a = c("a", "b", "c"),
                  b = c(1, 3, 4), c = c("f", "e", "d"),
                  row.names = paste0("rn", 1:3), stringsAsFactors = FALSE)
df2 <- data.frame(id = paste0("person", 3:1), a = c("c", "b", "a"),
                  b = c(1, 3, 4), d = paste0("rn", 1:3),
                  row.names = paste0("rn", c(1,3,2)), stringsAsFactors = FALSE)
summary(comparedf(df1, df2))
summary(comparedf(df1, df2, by = "id"))
summary(comparedf(df1, df2, by = "row.names"))

arsenal

An Arsenal of 'R' Functions for Large-Scale Statistical Summaries

v3.6.2
GPL (>= 2)
Authors
Ethan Heinzen [aut, cre], Jason Sinnwell [aut], Elizabeth Atkinson [aut], Tina Gunderson [aut], Gregory Dougherty [aut], Patrick Votruba [ctb], Ryan Lennon [ctb], Andrew Hanson [ctb], Krista Goergen [ctb], Emily Lundt [ctb], Brendan Broderick [ctb], Maddie McCullough [art]
Initial release
2021-02-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.