Skip to contents

Compare two data frames by columns

Usage

compareDataFrames(
  x,
  y,
  dbg = FALSE,
  xname = deparse(substitute(x)),
  yname = deparse(substitute(y))
)

Arguments

x

first data frame

y

second data frame

dbg

if TRUE (default) the result of comparing the dimensions and the column names is printed on the screen

xname

name of first data frame to appear in the output if dbg = TRUE

yname

name of second data frame to appear in the output if dbg = TRUE

Value

list of logical

Examples

x <- data.frame(a = 1:2, b = 2:3)
y <- x

test1 <- all(unlist(compareDataFrames(x, y)))

z <- compareDataFrames(x, y[, c("b", "a")])
expectedFalse <- c("identical", "identicalExceptAttributes", "sameColumnNames")
test2 <- all(names(which(!unlist(z))) == expectedFalse)

test1 && test2
#> [1] TRUE