compare | R Documentation |
compare()
creates a representation of the differences between two tables,
along with a shallow copy of the tables. This output is used
as the comparison
argument when exploring the differences further with other
versus functions e.g. slice_*()
and weave_*()
.
compare(table_a, table_b, by, allow_both_NA = TRUE, coerce = TRUE)
table_a |
A data frame |
table_b |
A data frame |
by |
< |
allow_both_NA |
Logical. If |
coerce |
Logical. If |
compare()
A list of data frames having the following elements:
A data frame with one row per input table showing the number of rows and columns in each.
A data frame with one row per by
column showing the class
of the column in each of the input tables.
A data frame with one row per column common to table_a
and
table_b
and columns "n_diffs" showing the number of values which
are different between the two tables, "class_a"/"class_b" the class of the
column in each table, and "value_diffs" a (nested) data frame showing
the the values in each table which are unequal and the by
columns
A data frame with one row per column which is in one input table but not the other and columns "table": which table the column appears in, "column": the name of the column, and "class": the class of the column.
A data frame which, for each row present in one input table but not
the other, contains the column "table" showing which table the row appears
in and the by
columns for that row.
If the input is a data.table, you may want compare()
to make a deep copy instead
of a shallow copy so that future changes to the table don't affect the comparison.
To achieve this, you can set options(versus.copy_data_table = TRUE)
.
compare(example_df_a, example_df_b, by = car)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.