
It creates columns to indicate the number of days between the current table and a target cohort
Source:R/addCohortIntersect.R
addCohortIntersectDays.Rd
It creates columns to indicate the number of days between the current table and a target cohort
Usage
addCohortIntersectDays(
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 days 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 |>
addCohortIntersectDays(targetCohortTable = "cohort2")
#> # Source: table<og_022_1740755673> [?? 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 2 8 1982-06-23 2013-07-17
#> 2 2 1 1944-11-23 1952-05-23
#> 3 1 7 1964-06-07 1976-06-27
#> 4 1 6 1988-04-23 1991-05-18
#> 5 3 9 1999-11-13 2003-03-08
#> 6 2 3 1990-10-06 1994-04-28
#> 7 1 5 2011-12-21 2013-09-02
#> 8 1 4 1928-04-04 1928-07-18
#> 9 2 10 1960-09-03 1968-09-06
#> 10 1 2 1999-04-23 2000-11-11
#> # ℹ 3 more variables: cohort_1_0_to_inf <dbl>, cohort_2_0_to_inf <dbl>,
#> # cohort_3_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }