Skip to contents

Motivation

The goal of the dfdiffs is to answer the following questions:

  1. What rows are here now that weren’t here before?
  2. What rows were here before that aren’t here now?
  3. What values have been changed?

Test data

These are two Masters tables from the Lahman baseball database.

m15 <- dfdiffs::master15 |> 
  dplyr::slice_sample(n = 3000, replace = FALSE)
max(m15$debut, na.rm = TRUE)
#> [1] "2015-09-13"
m20 <- dfdiffs::master20 |> 
  dplyr::slice_sample(n = 3000, replace = FALSE)
max(m20$debut, na.rm = TRUE)
#> [1] "2019-09-14"

The compare_data() function

compare_data(compare = , base = , by = , by_col = , cols = )
comparisons <- compare_data(
  compare = m20, base = m15, 
  by = "playerID", by_col = "join", 
  cols = c("nameFirst", "nameLast", "nameGiven", "height"))
#> Error in `tidyr::unite()`:
#> ! `sep` must be a single string, not absent.
names(comparisons)
#> Error:
#> ! object 'comparisons' not found

$new_data

comparisons$new_data
#> Error:
#> ! object 'comparisons' not found

$deleted_data

comparisons$deleted_data
#> Error:
#> ! object 'comparisons' not found

$changed_num_diffs

comparisons$changed_num_diffs
#> Error:
#> ! object 'comparisons' not found

$changed_var_diffs

comparisons$changed_var_diffs
#> Error:
#> ! object 'comparisons' not found