Pick a window before and after a metadata date column
cg_window_by_metadata.Rd
Pick a window before and after a metadata date column
Examples
data(pitch_chronogram)
pitch_chronogram
#> # A tibble: 395,051 × 23
#> # A chronogram: try summary()
#> calendar_date ID Centre_code Previous_infection Vaccine_interval
#> * <date> <fct> <int> <chr> <chr>
#> 1 2020-01-01 100 0 Y LONG
#> 2 2020-01-02 100 0 Y LONG
#> 3 2020-01-03 100 0 Y LONG
#> 4 2020-01-04 100 0 Y LONG
#> 5 2020-01-05 100 0 Y LONG
#> 6 2020-01-06 100 0 Y LONG
#> 7 2020-01-07 100 0 Y LONG
#> 8 2020-01-08 100 0 Y LONG
#> 9 2020-01-09 100 0 Y LONG
#> 10 2020-01-10 100 0 Y LONG
#> # ℹ 395,041 more rows
#> # ℹ 18 more variables: dose_1_date <date>, dose_2_date <date>, Victoria <int>,
#> # Beta <int>, Gamma <int>, Delta <chr>, Cov2_RBD_MSD <dbl>,
#> # Cov2_RBD_BAU <dbl>, Cov_2N_MSD <dbl>, Cov_2N_BAU <dbl>, Cov_2S_MSD <dbl>,
#> # Cov_2S_BAU <dbl>, HKU1_S <dbl>, MERS_S <dbl>, NL63_S <dbl>, OC43_S <dbl>,
#> # X229E_S <dbl>, Cov_1S <dbl>
#> # ★ Dates: calendar_date ★ IDs: ID
#> # ★ metadata: Centre_code, Previous_infection, Vaccine_interval, dose_1_date, dose_2_date
SevenDaysPrePostDose2 <- cg_window_by_metadata(
pitch_chronogram, dose_2_date, 7, 7
)
SevenDaysPrePostDose2
#> # A tibble: 8,218 × 23
#> # A chronogram: try summary()
#> calendar_date ID Centre_code Previous_infection Vaccine_interval
#> * <date> <fct> <int> <chr> <chr>
#> 1 2021-03-17 100 0 Y LONG
#> 2 2021-03-18 100 0 Y LONG
#> 3 2021-03-19 100 0 Y LONG
#> 4 2021-03-20 100 0 Y LONG
#> 5 2021-03-21 100 0 Y LONG
#> 6 2021-03-22 100 0 Y LONG
#> 7 2021-03-23 100 0 Y LONG
#> 8 2021-03-24 100 0 Y LONG
#> 9 2021-03-25 100 0 Y LONG
#> 10 2021-03-26 100 0 Y LONG
#> # ℹ 8,208 more rows
#> # ℹ 18 more variables: dose_1_date <date>, dose_2_date <date>, Victoria <int>,
#> # Beta <int>, Gamma <int>, Delta <chr>, Cov2_RBD_MSD <dbl>,
#> # Cov2_RBD_BAU <dbl>, Cov_2N_MSD <dbl>, Cov_2N_BAU <dbl>, Cov_2S_MSD <dbl>,
#> # Cov_2S_BAU <dbl>, HKU1_S <dbl>, MERS_S <dbl>, NL63_S <dbl>, OC43_S <dbl>,
#> # X229E_S <dbl>, Cov_1S <dbl>
#> # ★ Dates: calendar_date ★ IDs: ID
#> # ★ metadata: Centre_code, Previous_infection, Vaccine_interval, dose_1_date, dose_2_date