
To add a new column with the number of exposures. To add multiple columns use addDrugUtilisation()
for efficiency.
Source: R/addDrugUtilisation.R
addNumberExposures.Rd
To add a new column with the number of exposures. To add multiple columns use
addDrugUtilisation()
for efficiency.
Usage
addNumberExposures(
cohort,
conceptSet,
indexDate = "cohort_start_date",
censorDate = "cohort_end_date",
restrictIncident = TRUE,
nameStyle = "number_exposures_{concept_name}",
name = NULL
)
Arguments
- cohort
A cohort_table object.
- conceptSet
List of concepts to be included.
- 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 |>
addNumberExposures(conceptSet = codelist)
#> # Source: table<og_130_1743086368> [?? 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 1 2017-04-08 2017-11-19
#> 2 1 6 2008-07-19 2018-08-10
#> 3 1 8 1994-08-05 1995-01-19
#> 4 1 8 1997-11-04 2000-04-21
#> 5 1 4 2000-02-09 2000-04-28
#> 6 1 5 2015-02-20 2016-07-22
#> 7 1 5 2017-05-24 2020-01-12
#> 8 1 10 2016-05-29 2020-06-03
#> 9 1 2 2015-06-09 2016-08-05
#> # ℹ 1 more variable: number_exposures_161_acetaminophen <int>
# }