matchCohorts {CohortConstructor} | R Documentation |
matchCohorts()
generate a new cohort matched to individuals in an
existing cohort. Individuals can be matched based on year of birth and sex.
matchCohorts(
cohort,
cohortId = NULL,
matchSex = TRUE,
matchYearOfBirth = TRUE,
ratio = 1,
name = tableName(cohort)
)
cohort |
A cohort table in a cdm reference. |
cohortId |
IDs of the cohorts to include. If NULL all cohorts will be considered. Cohorts not included will be removed from the cohort set. |
matchSex |
Whether to match in sex. |
matchYearOfBirth |
Whether to match in year of birth. |
ratio |
Number of allowed matches per individual in the target cohort. |
name |
Name of the new generated cohort set. |
A cohort table.
library(CohortConstructor)
library(dplyr)
cdm <- mockCohortConstructor(nPerson = 200)
cdm$new_matched_cohort <- cdm$cohort2 |>
matchCohorts(
name = "new_matched_cohort",
cohortId = 2,
matchSex = TRUE,
matchYearOfBirth = TRUE,
ratio = 1)
cdm$new_matched_cohort