
Add drug restart information as a column per follow-up period of interest.
Source:R/summariseDrugRestart.R
addDrugRestart.Rd
Add drug restart information as a column per follow-up period of interest.
Usage
addDrugRestart(
cohort,
switchCohortTable,
switchCohortId = NULL,
followUpDays = Inf,
censorDate = NULL,
incident = TRUE,
nameStyle = "drug_restart_{follow_up_days}"
)
Arguments
- cohort
A cohort_table object.
- switchCohortTable
A cohort table in the cdm that contains possible alternative treatments.
- switchCohortId
The cohort ids to be used from switchCohortTable. If NULL all cohort definition ids are used.
- followUpDays
A vector of number of days to follow up. It can be multiple values.
- censorDate
Name of a column that indicates the date to stop the analysis, if NULL end of individuals observation is used.
- incident
Whether the switch treatment has to be incident (start after discontinuation) or not (it can start before the discontinuation and last till after).
- nameStyle
Character string to specify the nameStyle of the new columns.
Value
The cohort table given with additional columns with information on the restart, switch and not exposed per follow-up period of interest.
Examples
# \donttest{
library(DrugUtilisation)
cdm <- mockDrugUtilisation()
conceptlist <- list(acetaminophen = 1125360, metformin = c(1503297, 1503327))
cdm <- generateDrugUtilisationCohortSet(cdm = cdm,
name = "switch_cohort",
conceptSet = conceptlist)
#> ℹ Subsetting drug_exposure table
#> ℹ Checking whether any record needs to be dropped.
#> ℹ Collapsing overlaping records.
#> ℹ Collapsing records with gapEra = 1 days.
cdm$cohort1 |>
addDrugRestart(switchCohortTable = "switch_cohort")
#> # Source: table<og_046_1747174530> [?? x 5]
#> # 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 2 4 2003-07-29 2004-12-03
#> 2 2 5 1987-10-20 1989-01-26
#> 3 2 1 2010-08-21 2012-11-28
#> 4 2 8 2006-07-26 2007-10-16
#> 5 2 10 2013-08-19 2016-01-08
#> 6 3 2 2009-06-28 2009-08-04
#> 7 3 3 2020-10-09 2020-12-20
#> 8 2 6 1980-08-05 1987-08-19
#> 9 2 7 2022-07-10 2022-10-26
#> 10 3 9 2017-08-08 2018-11-26
#> # ℹ 1 more variable: drug_restart_inf <chr>
# }