Learn R Programming

DrugUtilisation (version 1.0.1)

addTreatment: Add a variable indicating individuals medications

Description

Add a variable to a drug cohort indicating their presence of a medication cohort in a specified time window.

Usage

addTreatment(
  cohort,
  treatmentCohortName,
  treatmentCohortId = NULL,
  window = list(c(0, 0)),
  indexDate = "cohort_start_date",
  censorDate = NULL,
  mutuallyExclusive = TRUE,
  nameStyle = NULL,
  name = NULL
)

Value

The original table with a variable added that summarises the individual´s indications.

Arguments

cohort

A cohort_table object.

treatmentCohortName

Name of treatment cohort table

treatmentCohortId

target cohort Id to add treatment

window

time window of interests.

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.

mutuallyExclusive

Whether to consider mutually exclusive categories (one column per window) or not (one column per window and treatment).

nameStyle

Name style for the treatment columns. By default: 'treatment_{window_name}' (mutuallyExclusive = TRUE), 'treatment_{window_name}_{cohort_name}' (mutuallyExclusive = FALSE).

name

Name of the new computed cohort table, if NULL a temporary table will be created.

Examples

Run this code
# \donttest{
cdm <- mockDrugUtilisation(numberIndividuals = 50)


cdm <- generateIngredientCohortSet(
  cdm = cdm, name = "drug_cohort", ingredient = "acetaminophen"
)

cdm <- generateIngredientCohortSet(
  cdm = cdm, name = "treatments", ingredient = c("metformin", "simvastatin")
)

cdm$drug_cohort |>
  addTreatment("treatments", window = list(c(0, 0), c(1, 30), c(31, 60))) |>
  dplyr::glimpse()
# }

Run the code above in your browser using DataLab