Compute the intersect with a target cohort, you can compute the number of occurrences, a flag of presence, a certain date and/or the time difference
Source:R/addCohortIntersect.R
addCohortIntersect.Rd
Compute the intersect with a target cohort, you can compute the number of occurrences, a flag of presence, a certain date and/or the time difference
Usage
addCohortIntersect(
x,
cdm = lifecycle::deprecated(),
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetStartDate = "cohort_start_date",
targetEndDate = "cohort_end_date",
window = list(c(0, Inf)),
order = "first",
flag = TRUE,
count = TRUE,
date = TRUE,
days = TRUE,
nameStyle = "{value}_{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
name of the cohort that we want to check for overlap.
- targetCohortId
vector of cohort definition ids to include.
- 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.
- targetStartDate
date of reference in cohort table, either for start (in overlap) or on its own (for incidence).
- targetEndDate
date of reference in cohort table, either for end (overlap) or NULL (if incidence).
- window
window to consider events of.
- order
which record is considered in case of multiple records.
- flag
TRUE or FALSE. If TRUE, flag will calculated for this intersection.
- count
TRUE or FALSE. If TRUE, the number of counts will be calculated for this intersection.
- date
TRUE or FALSE. If TRUE, date will be calculated for this intersection.
- days
TRUE or FALSE. If TRUE, time difference in days will be calculated for this intersection.
- nameStyle
naming of the added column or columns, should include required parameters.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addCohortIntersect(
targetCohortTable = "cohort2"
)
#> Warning: `addCohortIntersect()` was deprecated in PatientProfiles 0.6.0.
#> please use the specific functions instead:
#> • addCohortIntersectFlag()
#> • addCohortIntersectCount()
#> • addCohortIntersectDate()
#> • addCohortIntersectDays()
#> # Source: table<og_014_1715428917> [2 x 12]
#> # Database: DuckDB v0.10.2 [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
#> # ℹ 8 more variables: count_cohort_1_0_to_inf <dbl>,
#> # count_cohort_2_0_to_inf <dbl>, flag_cohort_1_0_to_inf <dbl>,
#> # flag_cohort_2_0_to_inf <dbl>, date_cohort_2_0_to_inf <date>,
#> # date_cohort_1_0_to_inf <date>, days_cohort_2_0_to_inf <dbl>,
#> # days_cohort_1_0_to_inf <dbl>
CDMConnector::cdmDisconnect(cdm = cdm)
# }