matchCohorts {CohortConstructor} | R Documentation |
Generate a new cohort matched cohort
Description
matchCohorts()
generate a new cohort matched to individuals in an
existing cohort. Individuals can be matched based on year of birth and sex.
Usage
matchCohorts(
cohort,
cohortId = NULL,
matchSex = TRUE,
matchYearOfBirth = TRUE,
ratio = 1,
name = tableName(cohort)
)
Arguments
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. |
Value
A cohort table.
Examples
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
[Package CohortConstructor version 0.2.1 Index]