
It creates columns to indicate the presence of cohorts
Source:R/addCohortIntersect.R
addCohortIntersectFlag.RdIt creates columns to indicate the presence of cohorts
Arguments
- x
Table with individuals in the cdm.
- targetCohortTable
name of the cohort that we want to check for overlap.
- targetCohortId
vector of cohort definition ids to include.
- indexDate
Variable in x that contains the date to compute the intersection.
- censorDate
whether to censor overlap events at a specific date or a column date of x.
- targetStartDate
date of reference in cohort table, either for start (in overlap) or on its own (for incidence).
- targetEndDate
date of reference in cohort table, either for end (overlap) or NULL (if incidence).
- window
window to consider events of.
- nameStyle
naming of the added column or columns, should include required parameters.
- name
Name of the new table, if NULL a temporary table is returned.
Value
The original table (x) with one added column per intersection with the desired cohort in a specific window. One column will be created for each combination of window and cohort. The value of the column can either be: 1 to indicate presence of the intersection, 0 to indicate no intersection or NA if the individual is not in observation at any time of the window.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectFlag(
targetCohortTable = "cohort2"
)
#> # Source: table<og_039_1775495247> [?? x 7]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 10 1965-11-28 1969-04-25
#> 2 2 9 1956-05-19 1976-05-24
#> 3 1 1 1983-05-26 1989-08-16
#> 4 2 4 1967-05-05 1967-12-31
#> 5 2 5 1971-04-16 1972-06-29
#> 6 2 8 1968-07-22 1969-11-04
#> 7 3 7 1924-04-18 1944-02-13
#> 8 2 2 1989-12-29 1999-02-04
#> 9 3 3 1965-01-07 1966-03-28
#> 10 3 6 1972-10-23 1976-08-17
#> # ℹ 3 more variables: cohort_3_0_to_inf <dbl>, cohort_1_0_to_inf <dbl>,
#> # cohort_2_0_to_inf <dbl>
# }