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<main.cohort1> [?? x 4]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1020-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 12 2000-11-15 2013-03-04
#> 2 1 23 2001-06-05 2003-08-26
#> 3 1 25 2018-06-27 2018-11-13
#> 4 1 31 2013-03-29 2014-04-29
#> 5 1 50 2019-05-08 2019-06-02
#> 6 1 63 2005-02-27 2005-05-14
#> 7 1 82 2004-02-05 2010-08-14
#> 8 1 84 1963-03-22 1981-05-30
#> 9 1 23 2000-10-08 2001-06-04
#> 10 1 25 2018-03-23 2018-06-26
#> # ℹ more rows
# }