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.
- 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<cohort1> [?? x 4]
#> # Database: DuckDB v1.2.1 [unknown@Linux 6.8.0-1021-azure:R 4.4.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 13 1992-11-03 2000-11-27
#> 2 1 16 2005-12-28 2008-06-11
#> 3 1 17 2009-06-18 2013-02-01
#> 4 1 27 1993-10-01 2003-08-01
#> 5 1 41 2000-07-02 2000-11-21
#> 6 1 53 1998-02-23 2001-04-23
#> 7 1 54 2014-11-14 2016-06-22
#> 8 1 76 2000-10-01 2007-07-27
#> 9 1 13 1991-04-14 1992-10-21
#> 10 1 27 1992-04-16 1993-09-30
#> # ℹ more rows
# }