
Date of cohorts that are present in a certain window
Source:R/addCohortIntersect.R
addCohortIntersectDate.Rd
Date of cohorts that are present in a certain window
Usage
addCohortIntersectDate(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
nameStyle = "{cohort_name}_{window_name}",
name = NULL
)
Arguments
- x
Table with individuals in the cdm.
- targetCohortTable
Cohort table to.
- targetCohortId
Cohort IDs of interest from the other cohort table. If NULL, all cohorts will be used with a time variable added for each cohort of interest.
- 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{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addCohortIntersectDate(targetCohortTable = "cohort2")
#> # Source: table<og_013_1748639723> [?? x 7]
#> # Database: DuckDB v1.2.2 [unknown@Linux 6.11.0-1015-azure:R 4.5.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 1 1985-02-17 2004-01-28
#> 2 2 8 1935-11-15 1952-03-08
#> 3 1 4 1913-10-23 1941-04-04
#> 4 3 10 1972-04-13 1998-04-07
#> 5 1 2 1982-07-04 1984-11-25
#> 6 3 9 1944-11-17 1946-12-04
#> 7 3 5 1938-11-13 1958-07-13
#> 8 2 7 1968-07-08 1973-11-26
#> 9 3 6 1952-05-27 1971-02-12
#> 10 1 3 1967-02-16 1974-09-04
#> # ℹ 3 more variables: cohort_2_0_to_inf <date>, cohort_3_0_to_inf <date>,
#> # cohort_1_0_to_inf <date>
mockDisconnect(cdm = cdm)
# }