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_016_1734613784> [?? x 7]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 6 1975-02-21 1991-05-08
#> 2 2 7 1960-03-14 1961-03-20
#> 3 1 1 1980-06-02 1986-12-30
#> 4 1 8 1980-08-25 1986-07-05
#> 5 3 3 1932-12-15 1949-05-21
#> 6 1 5 1954-09-05 1955-07-15
#> 7 2 2 1932-04-03 1933-03-11
#> 8 3 4 2011-11-12 2011-11-22
#> 9 3 10 1984-07-27 1986-04-05
#> 10 2 9 1954-07-16 1972-07-03
#> # ℹ 3 more variables: cohort_2_0_to_inf <date>, cohort_1_0_to_inf <date>,
#> # cohort_3_0_to_inf <date>
mockDisconnect(cdm = cdm)
# }