dplyr (version 0.2)

all.equal.tbl_df: Provide a useful implementation of all.equal for data.frames.

Description

Provide a useful implementation of all.equal for data.frames.

Usage

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

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

Arguments

target,current
two data frames to compare
ignore_col_order
should order of columns be ignored?
ignore_row_order
should order of rows be ignored?
convert
Should similar classes be converted? Currently this will convert factor to character and integer to double.
...
Ignored. Needed for compatibility with the generic.

Value

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

Examples

Run this code
scramble <- function(x) x[sample(nrow(x)), sample(ncol(x))]

# By default, ordering of rows and columns ignored
mtcars_df <- tbl_df(mtcars)
all.equal(mtcars_df, scramble(mtcars_df))

# But those can be overriden if desired
all.equal(mtcars_df, scramble(mtcars_df), ignore_col_order = FALSE)
all.equal(mtcars_df, scramble(mtcars_df), ignore_row_order = FALSE)

Run the code above in your browser using DataCamp Workspace