Erafy a cohort_table collapsing records separated gapEra days or less.
Source:R/erafyCohort.R
erafyCohort.Rd
Erafy a cohort_table collapsing records separated gapEra days or less.
Usage
erafyCohort(
cohort,
gapEra,
cohortId = NULL,
nameStyle = "{cohort_name}_{gap_era}",
name = omopgenerics::tableName(cohort)
)
Arguments
- cohort
A cohort_table object.
- gapEra
Number of days between two continuous exposures to be considered in the same era.
- cohortId
A cohort definition id to restrict by. If NULL, all cohorts will be included.
- nameStyle
String to create the new names of cohorts. Must contain '{cohort_name}' if more than one cohort is present and '{gap_era}' if more than one gapEra is provided.
- name
Name of the new cohort table, it must be a length 1 character vector.
Examples
# \donttest{
cdm <- mockDrugUtilisation()
cdm$cohort2 <- cdm$cohort1 |>
erafyCohort(gapEra = 30, name = "cohort2")
cdm$cohort2
#> # Source: table<main.cohort2> [?? x 4]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 2 1979-08-10 1983-06-09
#> 2 1 4 2017-07-27 2018-02-17
#> 3 2 3 2019-02-17 2019-03-17
#> 4 3 6 1985-01-31 1985-02-08
#> 5 1 8 2015-09-24 2015-10-22
#> 6 3 7 2017-09-30 2019-03-20
#> 7 2 1 2021-08-11 2021-10-12
#> 8 2 9 1995-04-14 2003-03-20
#> 9 2 10 2021-03-07 2021-03-24
#> 10 2 5 2019-05-06 2019-05-25
settings(cdm$cohort2)
#> # A tibble: 3 × 3
#> cohort_definition_id cohort_name gap_era
#> <int> <chr> <chr>
#> 1 1 cohort_1_30 30
#> 2 2 cohort_2_30 30
#> 3 3 cohort_3_30 30
mockDisconnect(cdm)
# }