requireDeathFlag {CohortConstructor} | R Documentation |
Require cohort subjects have (or do not have) a death record
Description
requireDeathFlag()
filters a cohort table based on a requirement
that an individual is seen (or not seen) to have a death in some time
window around an index date.
Usage
requireDeathFlag(
cohort,
window,
cohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
negate = FALSE,
name = tableName(cohort)
)
Arguments
cohort |
A cohort table in a cdm reference. |
window |
A list of vectors specifying minimum and maximum days from
|
cohortId |
Vector identifying which cohorts to modify (cohort_definition_id or cohort_name). If NULL, all cohorts will be used; otherwise, only the specified cohorts will be modified, and the rest will remain unchanged. |
indexDate |
Name of the column in the cohort that contains the date to use as time 0 for window days. |
censorDate |
Whether to censor overlap events at a specific date or a column date of the cohort. |
negate |
If set as TRUE, criteria will be applied as exclusion rather than inclusion (i.e. require absence in another cohort). |
name |
Name of the new cohort table created in the cdm object. |
Value
Cohort table with only those with a death event kept (or without if negate = TRUE)
Examples
library(CDMConnector)
library(CohortConstructor)
cdm <- mockCohortConstructor(death = TRUE)
cdm$cohort1 <- cdm$cohort1 |> requireDeathFlag(window = list(c(0, Inf)))
attrition(cdm$cohort1)