
It creates a column with the field of a desired intersection
Source:R/addCohortIntersect.R
addCohortIntersectField.RdIt creates a column with the field of a desired intersection
Arguments
- x
Table with individuals in the cdm.
- targetCohortTable
name of the cohort that we want to check for overlap.
- field
Column of interest in the targetCohort.
- 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.
- targetDate
Date of interest in the other cohort table. Either cohort_start_date or cohort_end_date.
- order
date to use if there are multiple records for an individual during the window of interest. Either first or last.
- window
Window of time to identify records relative to the indexDate. Records outside of this time period will be ignored.
- 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.
Examples
# \donttest{
library(PatientProfiles)
library(dplyr)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort2 <- cdm$cohort2 |>
mutate(even = if_else(subject_id %% 2, "yes", "no")) |>
compute(name = "cohort2")
cdm$cohort1 |>
addCohortIntersectFlag(
targetCohortTable = "cohort2"
)
#> # Source: table<og_029_1775495243> [?? 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 3 1923-12-15 1927-04-11
#> 2 2 7 1948-06-06 1967-07-13
#> 3 1 10 1943-09-24 1964-08-03
#> 4 3 4 1955-09-22 1963-07-08
#> 5 3 6 1967-03-06 1967-05-20
#> 6 2 9 1974-02-05 1984-08-03
#> 7 3 5 1943-06-11 1944-10-20
#> 8 1 8 1960-06-11 1962-10-29
#> 9 1 1 1933-01-11 1933-06-19
#> 10 1 2 1976-03-25 1977-04-21
#> # ℹ 3 more variables: cohort_3_0_to_inf <dbl>, cohort_1_0_to_inf <dbl>,
#> # cohort_2_0_to_inf <dbl>
# }