Add days to death for individuals. Only death within the same observation period than `indexDate` will be observed.
Source:R/addDeath.R
addDeathDays.Rd
Add days to death for individuals. Only death within the same observation period than `indexDate` will be observed.
Usage
addDeathDays(
x,
indexDate = "cohort_start_date",
censorDate = NULL,
window = c(0, Inf),
deathDaysName = "days_to_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.
- deathDaysName
name of the new column to be added.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addDeathDays()
#> # Source: table<og_099_1715898448> [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
#> <int> <int> <date> <date>
#> 1 3 8 2058-10-03 2066-10-19
#> 2 1 5 2041-10-03 2052-12-09
#> 3 1 4 2041-07-31 2041-09-20
#> 4 2 7 2037-06-11 2053-04-08
#> 5 2 10 2017-08-13 2029-05-11
#> 6 1 2 2075-01-31 2078-10-14
#> 7 2 6 2068-04-06 2111-03-12
#> 8 1 1 1943-12-05 1947-10-14
#> 9 2 3 1942-04-01 1966-03-18
#> 10 1 9 1998-03-02 2023-10-22
#> # ℹ 1 more variable: days_to_death <dbl>
mockDisconnect(cdm = cdm)
# }