Description Usage Arguments Value Examples
You can use all_equal()
with any data frame, and dplyr also provides
tbl_df
methods for all.equal()
.
1 2 3 4 5 6 |
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 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | scramble <- function(x) x[sample(nrow(x)), sample(ncol(x))]
# By default, ordering of rows and columns ignored
all_equal(mtcars, scramble(mtcars))
# But those can be overriden if desired
all_equal(mtcars, scramble(mtcars), ignore_col_order = FALSE)
all_equal(mtcars, scramble(mtcars), ignore_row_order = FALSE)
# By default all_equal is sensitive to variable differences
df1 <- data.frame(x = "a")
df2 <- data.frame(x = factor("a"))
all_equal(df1, df2)
# But you can request dplyr convert similar types
all_equal(df1, df2, convert = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.