
To add a new column with the number of eras. To add multiple columns use addDrugUtilisation()
for efficiency.
Source: R/addDrugUtilisation.R
addNumberEras.Rd
To add a new column with the number of eras. To add multiple columns use
addDrugUtilisation()
for efficiency.
Usage
addNumberEras(
cohort,
conceptSet,
gapEra,
indexDate = "cohort_start_date",
censorDate = "cohort_end_date",
restrictIncident = TRUE,
nameStyle = "number_eras_{concept_name}",
name = NULL
)
Arguments
- cohort
A cohort_table object.
- conceptSet
List of concepts to be included.
- gapEra
Number of days between two continuous exposures to be considered in the same era.
- indexDate
Name of a column that indicates the date to start the analysis.
- censorDate
Name of a column that indicates the date to stop the analysis, if NULL end of individuals observation is used.
- restrictIncident
Whether to include only incident prescriptions in the analysis. If FALSE all prescriptions that overlap with the study period will be included.
- nameStyle
Character string to specify the nameStyle of the new columns.
- name
Name of the new computed cohort table, if NULL a temporary table will be created.
Examples
# \donttest{
cdm <- mockDrugUtilisation()
codelist <- CodelistGenerator::getDrugIngredientCodes(
cdm,
name = "acetaminophen"
)
cdm <- generateDrugUtilisationCohortSet(
cdm = cdm, name = "dus_cohort", conceptSet = codelist
)
#> ℹ Subsetting drug_exposure table
#> ℹ Checking whether any record needs to be dropped.
#> ℹ Collapsing overlaping records.
#> ℹ Collapsing records with gapEra = 1 days.
cdm$dus_cohort |>
addNumberEras(conceptSet = codelist, gapEra = 1)
#> # Source: table<og_122_1743086361> [?? x 5]
#> # Database: DuckDB v1.2.1 [unknown@Linux 6.8.0-1021-azure:R 4.4.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 9 2018-09-12 2020-04-10
#> 2 1 1 2022-04-17 2022-05-22
#> 3 1 1 2022-05-24 2022-06-03
#> 4 1 7 2018-06-04 2018-07-30
#> 5 1 4 2020-09-29 2021-01-30
#> 6 1 6 2013-09-20 2014-12-12
#> 7 1 10 2021-03-21 2021-07-21
#> 8 1 3 2012-12-14 2016-02-29
#> 9 1 8 2009-05-25 2012-07-11
#> 10 1 2 1989-01-17 1990-05-30
#> # ℹ 1 more variable: number_eras_161_acetaminophen <int>
# }