Create cohorts based on patient demographics
demographicsCohort.Rd
demographicsCohort()
creates a cohort table based on patient
characteristics. If and when an individual satisfies all the criteria they
enter the cohort. When they stop satisfying any of the criteria their
cohort entry ends.
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
cohort <- cdm |>
demographicsCohort(name = "cohort3", ageRange = c(18,40), sex = "Male")
#> ! cohort columns will be reordered to match the expected order:
#> cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date.
#> ℹ Building new trimmed cohort
#> Adding demographics information
#> Creating initial cohort
#> Trim sex
#> Trim age
#> ✔ Cohort trimmed
attrition(cohort)
#> # A tibble: 3 × 7
#> cohort_definition_id number_records number_subjects reason_id reason
#> <int> <int> <int> <int> <chr>
#> 1 1 10 10 1 Initial qualify…
#> 2 1 2 2 2 Sex requirement…
#> 3 1 2 2 3 Age requirement…
#> # ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>
# }