unionCohorts {CohortConstructor}R Documentation

Generate cohort from the union of different cohorts

Description

unionCohorts() combines different cohort entries, with those records that overlap combined and kept. Cohort entries are when an individual was in either of the cohorts.

Usage

unionCohorts(
  cohort,
  cohortId = NULL,
  gap = 0,
  cohortName = NULL,
  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.

gap

Number of days between two subsequent cohort entries of a subject that will be merged in a single cohort entry

cohortName

Name of the returned cohort. If NULL, the cohort name will be created by collapsing the individual cohort names, separated by "_".

name

Name of the new cohort table.

Value

A cohort table.

Examples


library(CohortConstructor)

cdm <- mockCohortConstructor(nPerson = 100)

cdm$cohort2 <- cdm$cohort2 |> unionCohorts()
settings(cdm$cohort2)



[Package CohortConstructor version 0.2.1 Index]