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,
cdm = lifecycle::deprecated(),
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
nameStyle = "{cohort_name}_{window_name}"
)
Arguments
- x
Table with individuals in the cdm.
- cdm
Object that contains a cdm reference. Use CDMConnector to obtain a cdm reference.
- 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.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addCohortIntersectDays(
targetCohortTable = "cohort2"
)
#> # Source: table<og_037_1714466027> [2 x 6]
#> # Database: DuckDB v0.10.1 [unknown@Linux 6.5.0-1018-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <dbl> <dbl> <date> <date>
#> 1 1 1 2020-01-01 2020-04-01
#> 2 1 1 2020-06-01 2020-08-01
#> # ℹ 2 more variables: cohort_1_0_to_inf <dbl>, cohort_2_0_to_inf <dbl>
CDMConnector::cdmDisconnect(cdm = cdm)
# }