requireDrugInDateRange {DrugUtilisation} | R Documentation |
Restrict cohort to only cohort records within a certain date range
Description
Filter the cohort table keeping only the cohort records for which the specified index date is within a specified date range.
Usage
requireDrugInDateRange(
cohort,
dateRange,
indexDate = "cohort_start_date",
cohortId = NULL,
name = omopgenerics::tableName(cohort)
)
Arguments
cohort |
A cohort table in a cdm reference. |
dateRange |
Date interval to consider. Any records with the index date outside of this range will be dropped. |
indexDate |
The column containing the date that will be checked against the date range. |
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 date requirement.
Examples
library(DrugUtilisation)
library(dplyr)
cdm <- mockDrugUtilisation()
cdm$cohort1 <- cdm$cohort1 |>
requireDrugInDateRange(
dateRange = as.Date(c("2020-01-01", NA))
)
attrition(cdm$cohort1) |> glimpse()
[Package DrugUtilisation version 0.7.0 Index]