
It creates columns to indicate the number of days between the current table and a target cohort
Source:R/addCohortIntersect.R
addCohortIntersectDays.RdIt 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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectDays(targetCohortTable = "cohort2")
#> # Source: table<og_022_1775495240> [?? x 7]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 7 1920-09-26 1924-01-12
#> 2 3 8 1911-05-17 1915-01-30
#> 3 1 1 1979-10-28 1987-10-07
#> 4 3 5 1965-07-17 1966-01-19
#> 5 2 9 1984-06-26 1995-12-21
#> 6 3 3 1948-06-23 1954-11-23
#> 7 3 4 1938-03-28 1939-04-15
#> 8 1 6 1959-06-05 1959-07-16
#> 9 2 2 1951-08-23 1967-06-21
#> 10 1 10 1959-10-21 1959-12-22
#> # ℹ 3 more variables: cohort_3_0_to_inf <dbl>, cohort_2_0_to_inf <dbl>,
#> # cohort_1_0_to_inf <dbl>
# }