Compares a value with all previous values

combn_changes(...)

# S3 method for data.frame
combn_changes(.data, dttm, val, pt_id, ...)

# S3 method for POSIXct
combn_changes(dttm, val, pt_id, ...)

Arguments

...

Further optional arguments

.data

(data.frame) A data.frame, optional

dttm

DateTime column name, or vector of POSIXct if .data is not provided

val

Variable column name, or vector of units or numeric if .data is not provided

pt_id

Patient ID column name, or vector of characters or factors if .data is not provided

Value

Combinatorics changes of the same type provided (numeric or units)

Examples

combn_changes(aki_pt_data, dttm = "dttm_", val = "SCr_", pt_id = "pt_id_")
#> # A tibble: 8 × 5
#>   pt_id_ dttm_                  SCr_  D.SCr_ D.dttm_ 
#>   <chr>  <dttm>              [mg/dl] [mg/dl] <drtn>  
#> 1 pt1    2020-10-19 09:00:00    2.5    0.5   24 hours
#> 2 pt1    2020-10-20 09:00:00    3      0.5   24 hours
#> 3 pt1    2020-10-20 09:00:00    3      1     48 hours
#> 4 pt1    2020-10-24 15:00:00    3.65   0.25  30 hours
#> 5 pt1    2020-10-25 21:00:00    3.9    0.25  30 hours
#> 6 pt2    2020-10-18 22:00:00    3.4    0.100 12 hours
#> 7 pt2    2020-10-19 10:00:00    3.5    0.100 12 hours
#> 8 pt2    2020-10-19 10:00:00    3.5    0.200 24 hours

aki_pt_data %>%
  combn_changes(dttm_, SCr_, pt_id_)
#> # A tibble: 8 × 5
#>   pt_id_ dttm_                  SCr_  D.SCr_ D.dttm_ 
#>   <chr>  <dttm>              [mg/dl] [mg/dl] <drtn>  
#> 1 pt1    2020-10-19 09:00:00    2.5    0.5   24 hours
#> 2 pt1    2020-10-20 09:00:00    3      0.5   24 hours
#> 3 pt1    2020-10-20 09:00:00    3      1     48 hours
#> 4 pt1    2020-10-24 15:00:00    3.65   0.25  30 hours
#> 5 pt1    2020-10-25 21:00:00    3.9    0.25  30 hours
#> 6 pt2    2020-10-18 22:00:00    3.4    0.100 12 hours
#> 7 pt2    2020-10-19 10:00:00    3.5    0.100 12 hours
#> 8 pt2    2020-10-19 10:00:00    3.5    0.200 24 hours