requirePriorDrugWashout {DrugUtilisation} | R Documentation |
Restrict cohort to only cohort records with a given amount of time since the last cohort record ended
Description
Filter the cohort table keeping only the cohort records for which the required amount of time has passed since the last cohort entry ended for that individual.
Usage
requirePriorDrugWashout(
cohort,
days,
cohortId = NULL,
name = omopgenerics::tableName(cohort)
)
Arguments
cohort |
A cohort table in a cdm reference. |
days |
The number of days required to have passed since the last cohort
record finished. Any records with fewer days than this will be dropped. Note
that setting days to Inf will lead to the same result as that from using the
|
cohortId |
IDs of the cohorts to modify. The default is NULL meaning all cohorts will be used; otherwise, only the specified cohorts will be modified, and the rest will remain unchanged. |
name |
Name of the table with the filtered cohort records. The default name is the original cohort name, where the original table will be overwritten. |
Value
The cohort table having applied the washout requirement.
Examples
library(DrugUtilisation)
library(dplyr)
cdm <- mockDrugUtilisation()
cdm$cohort1 <- cdm$cohort1 |>
requirePriorDrugWashout(days = 90)
attrition(cdm$cohort1) |> glimpse()