
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{
library(DrugUtilisation)
cdm <- mockDrugUtilisation()
cdm$cohort2 <- cdm$cohort1 |>
erafyCohort(gapEra = 30, name = "cohort2")
cdm$cohort2
#> # Source: table<cohort2> [?? x 4]
#> # Database: DuckDB v1.2.2 [unknown@Linux 6.11.0-1012-azure:R 4.5.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 1 2019-07-07 2019-09-17
#> 2 3 8 2009-09-10 2013-10-12
#> 3 1 3 2013-03-20 2014-05-05
#> 4 1 9 2015-12-04 2017-01-28
#> 5 1 6 2022-11-25 2022-12-04
#> 6 2 4 2012-10-11 2013-08-23
#> 7 3 5 2004-06-07 2009-02-26
#> 8 1 10 2008-10-02 2009-04-14
#> 9 3 2 2020-09-13 2021-04-09
#> 10 1 7 2013-11-12 2016-08-11
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)
# }