Select a visit within a windowed chronogram
cg_select_visit.Rd
Select a visit within a windowed chronogram
Usage
cg_select_visit(cg, visit_col = NULL, visit = c("earliest", "latest"))
Examples
data(pitch_chronogram)
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
## every visit has the assay `Cov_2S_MSD`
## therefore use this column to indicate a study visit
SevenDaysPrePostDose2_visits <- cg_select_visit(
SevenDaysPrePostDose2, Cov_2S_MSD, "earliest"
)
SevenDaysPrePostDose2_visits
#> # A tibble: 22 × 23
#> # A chronogram: try summary()
#> calendar_date ID Centre_code Previous_infection Vaccine_interval
#> * <date> <fct> <int> <chr> <chr>
#> 1 2021-04-10 1004 1 Y LONG
#> 2 2021-02-12 1009 1 Y LONG
#> 3 2021-03-30 1016 1 Y LONG
#> 4 2021-02-05 1018 1 Y LONG
#> 5 2021-03-15 1023 1 N LONG
#> 6 2021-03-12 1027 1 N LONG
#> 7 2021-03-28 1031 1 Y LONG
#> 8 2021-03-22 1034 1 Y LONG
#> 9 2021-03-10 1058 1 Y LONG
#> 10 2021-02-10 1060 1 N SHORT
#> # ℹ 12 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
## all days without visits are now dropped. Compare:
nrow(SevenDaysPrePostDose2)
#> [1] 8218
nrow(SevenDaysPrePostDose2_visits)
#> [1] 22