When comparing two
all.equal(), column and
row order is ignored by default, and types are not coerced. The
package is necessary to use this function.
all_equal(target, current, ignore_col_order = TRUE, ignore_row_order = TRUE, convert = FALSE, ...) # S3 method for tbl_df all.equal(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
TRUE if equal, otherwise a character vector describing
the reasons why they're not equal. Use
isTRUE() if using the
result in an
scramble <- function(x) x[sample(nrow(x)), sample(ncol(x))] mtcars_df <- as_tibble(mtcars) # By default, ordering of rows and columns ignored all.equal(mtcars_df, scramble(mtcars_df))#>  TRUE# But those can be overriden if desired all.equal(mtcars_df, scramble(mtcars_df), ignore_col_order = FALSE)#>  "Same column names, but different order"all.equal(mtcars_df, scramble(mtcars_df), ignore_row_order = FALSE)#>  "Same row values, but different order"# By default all.equal is sensitive to variable differences df1 <- tibble(x = "a") df2 <- tibble(x = factor("a")) all.equal(df1, df2)#>  "Incompatible type for column 'x': x character, y factor"# But you can request to convert similar types all.equal(df1, df2, convert = TRUE)#> Warning: joining character vector and factor, coercing into character vector#>  TRUE