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_023_1730219819> [10 x 7]
#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 7 1919-03-21 1925-01-30
#> 2 3 3 1965-04-19 1977-09-17
#> 3 1 6 1935-07-19 1982-03-27
#> 4 2 2 1974-01-19 1976-01-31
#> 5 3 9 1971-12-31 1973-05-13
#> 6 1 1 1934-07-19 1949-06-19
#> 7 1 10 1975-01-12 1977-07-09
#> 8 1 5 1983-08-29 1991-03-27
#> 9 3 8 1906-06-10 1916-04-08
#> 10 1 4 1957-02-02 1958-05-19
#> # ℹ 3 more variables: cohort_3_0_to_inf <dbl>, cohort_1_0_to_inf <dbl>,
#> # cohort_2_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }