Create changed data
create_changed_data.Rd
Create changed data
Arguments
- compare
A 'current' or 'new' dataset (tibble or data.frame)
- base
A 'previous' or 'old' dataset (tibble or data.frame)
- by
A join bs4Dash::column between the two datasets, or any combination of columns that constitute a unique row.
- by_col
A new name for the joining bs4Dash::column.
- cols
Columns to be compared.
Examples
# with local data
ChangedData <- dfdiffs::ChangedData
InitialData <- dfdiffs::InitialData
create_changed_data(
compare = ChangedData,
base = InitialData,
by = c("subject_id", "record"),
cols = c("text_value_a", "text_value_b", "updated_date")
)
#> $num_diffs
#> # A tibble: 3 × 2
#> variable no_of_differences
#> <chr> <int>
#> 1 text_value_a 2
#> 2 text_value_b 1
#> 3 updated_date 5
#>
#> $var_diffs
#> # A tibble: 8 × 4
#> variable join base compare
#> <chr> <chr> <chr> <chr>
#> 1 text_value_a A-1 Issue unresolved Issue resolved
#> 2 text_value_a A-2 Issue unresolved Issue resolved
#> 3 text_value_b C-4 Joint pain Joint pain, stiffness and swelling
#> 4 updated_date A-1 2021-09-29 2021-10-03
#> 5 updated_date A-2 2021-10-03 2021-11-27
#> 6 updated_date B-3 2021-09-02 2021-10-20
#> 7 updated_date C-4 2021-10-03 2021-10-13
#> 8 updated_date C-5 2021-09-20 2021-10-14
#>
create_changed_data(
compare = ChangedData,
base = InitialData,
by = c("subject_id", "record")
)
#> $num_diffs
#> # A tibble: 4 × 2
#> variable no_of_differences
#> <chr> <int>
#> 1 text_value_a 2
#> 2 text_value_b 1
#> 3 updated_date 5
#> 4 entered_date 5
#>
#> $var_diffs
#> # A tibble: 13 × 4
#> variable join base compare
#> <chr> <chr> <chr> <chr>
#> 1 text_value_a A-1 Issue unresolved Issue resolved
#> 2 text_value_a A-2 Issue unresolved Issue resolved
#> 3 text_value_b C-4 Joint pain Joint pain, stiffness and swelling
#> 4 updated_date A-1 2021-09-29 2021-10-03
#> 5 updated_date A-2 2021-10-03 2021-11-27
#> 6 updated_date B-3 2021-09-02 2021-10-20
#> 7 updated_date C-4 2021-10-03 2021-10-13
#> 8 updated_date C-5 2021-09-20 2021-10-14
#> 9 entered_date A-1 2021-09-29 2021-11-30
#> 10 entered_date A-2 2021-10-29 2021-11-30
#> 11 entered_date B-3 2021-08-18 2021-11-21
#> 12 entered_date C-4 2021-10-03 2021-11-11
#> 13 entered_date C-5 2021-10-20 2021-11-16
#>