To add a new column with the cumulative quantity. To add multiple columns use addDrugUtilisation()
for efficiency.
Source: R/addDrugUtilisation.R
addCumulativeQuantity.Rd
To add a new column with the cumulative quantity. To add multiple columns use
addDrugUtilisation()
for efficiency.
Usage
addCumulativeQuantity(
cohort,
conceptSet,
indexDate = "cohort_start_date",
censorDate = "cohort_end_date",
restrictIncident = TRUE,
nameStyle = "cumulative_quantity_{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{
library(DrugUtilisation)
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 |>
addCumulativeQuantity(conceptSet = codelist)
#> # Source: table<og_017_1734615682> [?? x 5]
#> # 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 7 2018-01-22 2021-05-13
#> 2 1 4 1999-10-05 2000-11-15
#> 3 1 9 1990-08-16 2001-02-02
#> 4 1 1 2020-08-28 2020-12-27
#> 5 1 2 2012-04-09 2015-08-06
#> 6 1 4 1997-06-17 1999-03-05
#> 7 1 9 2002-09-15 2005-04-21
#> 8 1 6 2018-01-29 2020-07-27
#> # ℹ 1 more variable: cumulative_quantity_161_acetaminophen <dbl>
# }