
Add days to death for individuals. Only death within the same observation period than indexDate will be observed.
Source: R/addDeath.R
addDeathDays.RdAdd 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",
name = NULL,
type = "numeric"
)Arguments
- x
A table containing individuals in a CDM reference.
- indexDate
Name of a date column in
x, or a single date to use for all rows, used as the reference date.- censorDate
Date or name of a date column in
xon which to censor follow-up. IfNULL, no censoring is applied.- window
Window or windows of time relative to
indexDateto consider.- deathDaysName
name of the new column to be added.
- name
Name of the new table. If
NULL, a temporary table is returned.- type
Type of the created column(s). Counts, days, age, and observation durations can be
"numeric"or"integer". Flag columns can also be"logical". Field columns can use"auto"to preserve the source type, or can be converted to"numeric","integer","logical", or"character".
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDeathDays()
#> # A query: ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 4 1947-11-10 1950-09-03
#> 2 3 8 1912-05-31 1920-01-15
#> 3 2 6 1926-11-21 1949-01-30
#> 4 2 2 1964-05-20 1965-02-11
#> 5 1 5 1960-04-25 1968-03-19
#> 6 3 10 1985-12-12 1996-07-15
#> 7 3 9 2010-05-06 2012-02-02
#> 8 1 1 1960-07-23 1965-08-28
#> 9 2 7 1942-08-20 1966-08-07
#> 10 3 3 1954-06-10 1954-08-29
#> # ℹ 1 more variable: days_to_death <dbl>
# }