Skip to contents

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",
  name = NULL
)

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.

name

Name of the new table, if NULL a temporary table is returned.

Value

table x with the added column with death information added.

Examples

# \donttest{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addDeathDays()
#> # Source:   table<og_098_1757798530> [?? x 5]
#> # Database: DuckDB 1.3.3-dev231 [unknown@Linux 6.11.0-1018-azure:R 4.5.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    1          1 1953-09-20        1988-02-04     
#>  2                    3          5 1967-03-21        1973-04-13     
#>  3                    1          6 2001-08-04        2002-04-07     
#>  4                    2         10 1969-04-25        1969-08-04     
#>  5                    2          2 1985-02-08        2006-03-25     
#>  6                    3          9 1923-07-23        1924-07-06     
#>  7                    2          3 1963-09-09        1964-10-12     
#>  8                    1          4 1910-12-12        1918-06-07     
#>  9                    3          7 1965-02-21        1970-10-11     
#> 10                    2          8 1919-11-24        1920-01-18     
#> # ℹ 1 more variable: days_to_death <dbl>

# }