Add flag for death for individuals. Only death within the same observation period than `indexDate` will be observed.
Source:R/addDeath.R
addDeathFlag.Rd
Add flag for death for individuals. Only death within the same observation period than `indexDate` will be observed.
Usage
addDeathFlag(
x,
indexDate = "cohort_start_date",
censorDate = NULL,
window = c(0, Inf),
deathFlagName = "death"
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the window origin.
- censorDate
Name of a column to stop followup.
- window
window to consider events over.
- deathFlagName
name of the new column to be added.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addDeathFlag()
#> # Source: table<og_110_1715898452> [10 x 5]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date death
#> <int> <int> <date> <date> <dbl>
#> 1 2 8 2017-03-14 2034-12-11 0
#> 2 3 7 2081-02-23 2109-08-27 0
#> 3 2 6 1932-06-27 1964-08-29 0
#> 4 3 1 2035-12-16 2060-03-10 0
#> 5 3 10 2071-05-06 2167-02-05 0
#> 6 1 4 1969-02-24 1969-07-21 0
#> 7 1 2 2033-12-19 2063-05-27 0
#> 8 2 5 1948-08-01 1973-08-25 0
#> 9 1 9 2014-11-07 2071-04-23 0
#> 10 2 3 1982-12-26 2093-01-28 0
mockDisconnect(cdm = cdm)
# }