View source: R/stratifyCohorts.R
stratifyCohorts | R Documentation |
stratifyCohorts()
creates new cohorts, splitting an existing cohort based
on specified columns on which to stratify on.
stratifyCohorts(
cohort,
strata,
cohortId = NULL,
removeStrata = TRUE,
name = tableName(cohort),
.softValidation = TRUE
)
cohort |
A cohort table in a cdm reference. |
strata |
A strata list that point to columns in cohort table. |
cohortId |
Vector identifying which cohorts to include (cohort_definition_id or cohort_name). Cohorts not included will be removed from the cohort set. |
removeStrata |
Whether to remove strata columns from final cohort table. |
name |
Name of the new cohort table created in the cdm object. |
.softValidation |
Whether to perform a soft validation of consistency. If set to FALSE four additional checks will be performed: 1) a check that cohort end date is not before cohort start date, 2) a check that there are no missing values in required columns, 3) a check that cohort duration is all within observation period, and 4) that there are no overlapping cohort entries |
Cohort table stratified.
library(CohortConstructor)
library(PatientProfiles)
cdm <- mockCohortConstructor()
cdm$my_cohort <- cdm$cohort1 |>
addAge(ageGroup = list("child" = c(0, 17), "adult" = c(18, Inf))) |>
addSex(name = "my_cohort") |>
stratifyCohorts(
strata = list("sex", c("sex", "age_group")), name = "my_cohort"
)
cdm$my_cohort
settings(cdm$my_cohort)
attrition(cdm$my_cohort)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.