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(nPerson = 100)
cdm$cohort1 |> trimDemographics(ageRange = list(c(10, 30)))
#> ℹ Building new trimmed cohort
#> Adding demographics information
#> Creating initial cohort
#> Trim age
#> ✔ Cohort trimmed
#> # Source: table<cohort1> [?? x 4]
#> # Database: DuckDB 1.4.0 [unknown@Linux 6.11.0-1018-azure:R 4.5.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 12 2003-02-09 2007-02-05
#> 2 1 17 1979-09-09 1983-01-12
#> 3 1 25 2014-09-08 2014-11-21
#> 4 1 31 2019-06-13 2019-07-07
#> 5 1 50 2018-12-30 2019-04-05
#> 6 1 63 2000-09-28 2001-10-18
#> 7 1 82 2010-11-08 2012-11-27
#> 8 1 25 2014-03-04 2014-07-26
#> 9 1 31 2019-04-25 2019-06-11
#> 10 1 50 2018-05-18 2018-09-21
#> # ℹ more rows
# }