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

Window to consider events over.

cohortId

IDs of the cohorts to modify. If NULL, all cohorts will be used; otherwise, only the specified cohorts will be modified, and the rest will remain unchanged.

indexDate

Variable in x that contains the date to compute the intersection.

censorDate

Whether to censor overlap events at a specific date or a column date of x.

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 with the future observation restriction.

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)


[Package CohortConstructor version 0.2.1 Index]