requireAge()
filters cohort records, keeping only records where individuals
satisfy the specified age criteria.
Usage
requireAge(
cohort,
ageRange,
cohortId = NULL,
indexDate = "cohort_start_date",
atFirst = FALSE,
name = tableName(cohort)
)
Arguments
- cohort
A cohort table in a cdm reference.
- ageRange
A list of vectors specifying minimum and maximum age.
- 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.
- atFirst
If FALSE the requirement will be applied to all records, if TRUE, it will only be required for the first entry of each subject.
- name
Name of the new cohort table created in the cdm object.
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
cdm$cohort1 |>
requireAge(indexDate = "cohort_start_date",
ageRange = list(c(18, 65)))
#> # A tibble: 42 × 4
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> * <int> <int> <date> <date>
#> 1 1 1 2019-07-12 2019-08-09
#> 2 1 2 2004-03-19 2017-03-10
#> 3 1 3 1997-08-01 1998-12-26
#> 4 1 5 1995-05-29 1997-08-18
#> 5 1 10 2015-01-11 2016-09-24
#> 6 1 11 2013-10-14 2015-12-31
#> 7 1 12 2011-12-23 2012-10-25
#> 8 1 14 2003-08-08 2004-12-12
#> 9 1 16 1991-09-03 1999-01-01
#> 10 1 21 2015-02-12 2015-02-26
#> # ℹ 32 more rows
# }