trimDemographics()
resets the cohort start and end date based on the
specified demographic criteria is satisfied.
Usage
trimDemographics(
cohort,
cohortId = NULL,
ageRange = NULL,
sex = NULL,
minPriorObservation = NULL,
minFutureObservation = NULL,
name = tableName(cohort)
)
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.
- 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()
cdm$cohort1 |>
trimDemographics(ageRange = list(c(10, 30)))
#> ℹ Building new trimmed cohort
#> Adding demographics information
#> Creating initial cohort
#> Trim age
#> ✔ Cohort trimmed
#> # A tibble: 39 × 4
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 2 2008-02-22 2008-03-01
#> 2 1 3 1984-01-17 1984-01-26
#> 3 1 5 1995-12-11 1998-01-16
#> 4 1 8 1988-11-23 1991-10-29
#> 5 1 10 1986-11-08 1987-10-27
#> 6 1 11 2019-12-28 2019-12-30
#> 7 1 13 2008-11-17 2010-09-23
#> 8 1 16 2009-01-09 2009-05-17
#> 9 1 17 2010-07-09 2011-10-16
#> 10 1 20 1992-01-24 1993-12-10
#> # ℹ 29 more rows
# }