
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_019_1748639726> [?? 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 9 1991-06-24 1999-10-15
#> 2 2 3 1973-03-11 1981-10-30
#> 3 2 4 1965-11-07 1973-05-07
#> 4 1 10 1917-06-07 1922-11-13
#> 5 1 1 1971-08-17 1973-04-29
#> 6 2 7 1980-06-13 2003-03-02
#> 7 1 6 1920-01-01 1921-07-22
#> 8 2 5 1986-11-23 1990-03-18
#> 9 1 8 1919-03-31 1920-01-01
#> 10 1 2 1997-05-07 2000-05-31
#> # ℹ 3 more variables: cohort_3_0_to_inf <dbl>, cohort_1_0_to_inf <dbl>,
#> # cohort_2_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }