is_equal_df | R Documentation |
Compares two data frames/tibbles (or two objects coercible to tibbles like matrices), optionally
ignoring row and column ordering, and returns TRUE
if both are equal, or FALSE
otherwise. If the latter is the case and quiet = FALSE
, information
about detected differences is printed to the console.
is_equal_df(
x,
y,
ignore_col_order = FALSE,
ignore_row_order = FALSE,
ignore_col_types = FALSE,
tolerance = NULL,
quiet = TRUE,
max_diffs = 10L,
return_waldo_compare = FALSE
)
x |
The data frame / tibble to check for changes. |
y |
The data frame / tibble that |
ignore_col_order |
Whether or not to ignore the order of columns. |
ignore_row_order |
Whether or not to ignore the order of rows. |
ignore_col_types |
Whether or not to distinguish similar column types. Currently, if set to |
tolerance |
If non- It uses the same algorithm as |
quiet |
Whether or not to output detected differences between |
max_diffs |
Maximum number of differences shown. Only relevant if |
return_waldo_compare |
Whether to return a character vector of class |
Under the hood, this function relies on waldo::compare()
.
If return_waldo_compare = FALSE
, a logical scalar indicating the result of the comparison. Otherwise a character vector of class
waldo_compare
describing the differences between x
and y
.
Other data frame / tibble functions:
assert_cols()
,
reduce_df_list()
scramble <- function(x) x[sample(nrow(x)), sample(ncol(x))]
# by default, ordering of rows and columns matters...
pal::is_equal_df(x = mtcars,
y = scramble(mtcars))
# ...but those can be ignored if desired
pal::is_equal_df(x = mtcars,
y = scramble(mtcars),
ignore_col_order = TRUE)
pal::is_equal_df(x = mtcars,
y = scramble(mtcars),
ignore_row_order = TRUE)
# by default, `is_equal_df()` is sensitive to column type differences...
df1 <- data.frame(x = "a",
stringsAsFactors = FALSE)
df2 <- data.frame(x = factor("a"))
pal::is_equal_df(df1, df2)
# ...but you can request it to not make a difference between similar types
pal::is_equal_df(df1, df2,
ignore_col_types = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.