
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_014_1740755670> [?? x 7]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 6 1947-12-12 1955-06-12
#> 2 1 9 1927-04-25 1933-08-17
#> 3 1 4 1986-10-25 2000-09-03
#> 4 3 5 1949-08-30 1958-03-08
#> 5 1 7 1995-06-13 2004-04-24
#> 6 2 8 1985-12-25 1986-08-14
#> 7 2 3 1953-10-29 1958-06-25
#> 8 1 2 1939-01-24 1951-07-10
#> 9 3 10 1995-11-27 1996-11-28
#> 10 2 1 1932-08-31 1937-11-30
#> # ℹ 3 more variables: cohort_2_0_to_inf <date>, cohort_3_0_to_inf <date>,
#> # cohort_1_0_to_inf <date>
mockDisconnect(cdm = cdm)
# }