show_diff | R Documentation |
Compares two data frames/tibbles (or two objects coercible to tibbles like matrices) and offers to inspect any differences in tabular diff format as neatly rendered HTML.
show_diff(
x,
y,
ignore_order = FALSE,
ignore_col_types = FALSE,
ids = NULL,
ask = TRUE,
bypass_rstudio_viewer = FALSE,
verbose = TRUE,
max_diffs = 10L,
diff_text = "{x_lbl} is different from {y_lbl}",
ask_text = "Do you wish to display the changes in tabular diff format?",
caption = "{x_lbl} → {y_lbl}",
...
)
x |
The data frame / tibble to check for changes. |
y |
The data frame / tibble that |
ignore_order |
Whether or not to ignore the order of columns and rows. |
ignore_col_types |
Whether or not to distinguish similar column types. Currently, if set to |
ids |
A character vector of column names that make up a primary key, if known. If |
ask |
Whether or not to ask interactively if the resulting difference object should be opened in case |
bypass_rstudio_viewer |
If |
verbose |
Whether or not to also output the differences detected by |
max_diffs |
The maximum number of differences shown on the console. Only relevant if |
diff_text |
The text to display on the console in case |
ask_text |
The text that is displayed when |
caption |
The caption of the rendered difference object. It is passed to |
... |
Further arguments passed on to |
This function is basically a convenience wrapper combining pal::is_equal_df()
, daff::diff_data()
and daff::render_diff()
. If run non-interactively or
ask = FALSE
, the differences will be shown right away, otherwise the user will be asked on the console.
Note that in tabular diff format, only changes in the column content of x
and y
are visible, meaning that the following properties and changes
therein won't be displayed:
column types (e.g. integer vs. double)
row names and other attributes
A difference object, invisibly. It could be rendered later using daff::render_diff()
, for example.
Other data frame / tibble functions:
open_as_tmp_spreadsheet()
## Not run:
library(magrittr)
mtcars |>
dplyr::mutate(dplyr::across(c(cyl, gear),
\(x) dplyr::if_else(x > 4, x * 2, x))) |>
yay::show_diff(mtcars)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.