You can use all_equal() with any data frame, and dplyr also provides tbl_df methods for all.equal().

all_equal(target, current, ignore_col_order = TRUE,
  ignore_row_order = TRUE, convert = FALSE, ...)

# S3 method for tbl_df
all.equal(target, current, ignore_col_order = TRUE,
  ignore_row_order = TRUE, convert = FALSE, ...)


target, current

Two data frames to compare.


Should order of columns be ignored?


Should order of rows be ignored?


Should similar classes be converted? Currently this will convert factor to character and integer to double.


Ignored. Needed for compatibility with all.equal().


TRUE if equal, otherwise a character vector describing the reasons why they're not equal. Use isTRUE() if using the result in an if expression.


scramble <- function(x) x[sample(nrow(x)), sample(ncol(x))] # By default, ordering of rows and columns ignored all_equal(mtcars, scramble(mtcars))
#> [1] TRUE
# But those can be overriden if desired all_equal(mtcars, scramble(mtcars), ignore_col_order = FALSE)
#> [1] "Same column names, but different order"
all_equal(mtcars, scramble(mtcars), ignore_row_order = FALSE)
#> [1] "Same row values, but different order"
# By default all_equal is sensitive to variable differences df1 <- data.frame(x = "a") df2 <- data.frame(x = factor("a")) all_equal(df1, df2)
#> [1] TRUE
# But you can request dplyr convert similar types all_equal(df1, df2, convert = TRUE)
#> [1] TRUE