requireDemographics()
filters cohort records, keeping only records where
individuals satisfy the specified demographic criteria.
Arguments
- cohort
A cohort table in a cdm reference.
- 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
Variable in cohort that contains the date to compute the demographics characteristics on which to restrict on.
- ageRange
A list of vectors specifying minimum and maximum age.
- sex
Can be "Both", "Male" or "Female".
- minPriorObservation
A minimum number of continuous prior observation days in the database.
- minFutureObservation
A minimum number of continuous future observation days in the database.
- requirementInteractions
If TRUE, cohorts will be created for all combinations of ageGroup, sex, and daysPriorObservation. If FALSE, only the first value specified for the other factors will be used. Consequently, order of values matters when requirementInteractions is FALSE.
- name
Name of the new cohort table created in the cdm object.
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor(nPerson = 100)
cdm$cohort1 |>
requireDemographics(indexDate = "cohort_start_date",
ageRange = list(c(18, 65)),
sex = "Female",
minPriorObservation = 365)
#> # Source: table<main.cohort1> [?? x 4]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 13 1991-04-14 1992-10-21
#> 2 1 13 1992-11-03 2000-11-27
#> 3 1 16 2005-12-28 2008-06-11
#> 4 1 17 2009-06-18 2013-02-01
#> 5 1 27 1992-04-16 1993-09-30
#> 6 1 27 1993-10-01 2003-08-01
#> 7 1 41 2000-07-02 2000-11-21
#> 8 1 41 2000-11-22 2010-05-13
#> 9 1 53 1997-03-26 1998-02-22
#> 10 1 53 1998-02-23 2001-04-23
#> # ℹ more rows
# }