
Add flag for death for individuals. Only death within the same observation period than indexDate will be observed.
Source: R/addDeath.R
addDeathFlag.RdAdd 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",
name = NULL
)Value
The original table (x) with one added column per window indicating whether the individual's death record intersects that window. The value of the column can either be: 1 to indicate presence of the intersection, 0 to indicate no intersection or NA if the individual is not in observation at any time of the window.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDeathFlag()
#> # Source: table<og_121_1775495295> [?? x 5]
#> # 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 death
#> <int> <int> <date> <date> <dbl>
#> 1 3 2 1961-04-15 1963-03-29 0
#> 2 3 6 1930-01-12 1931-06-03 0
#> 3 3 3 1983-05-14 1992-01-24 0
#> 4 2 5 1964-08-14 1981-10-16 0
#> 5 2 8 1937-09-13 1945-12-06 0
#> 6 3 9 2002-05-10 2003-07-29 0
#> 7 2 4 1971-03-17 1972-07-17 0
#> 8 2 10 1971-04-24 1980-03-26 0
#> 9 3 1 1992-10-21 1999-08-30 0
#> 10 2 7 1955-02-22 1957-02-21 0
# }