-
Notifications
You must be signed in to change notification settings - Fork 1
death_functions
The rads package has a suite of
tools designed to facilitate and accelerate the analysis of standardized
death data. Combining the rads functions below with the clean death
data should allow APDE analysts to conduct custom analyses with relative
ease.
The core rads death functions are:
-
death_icd10_clean(): clean and standardize ICD-10 codes for use withradsdeath functions -
death_validate_data(): validates that a dataset meets the requirements for use withradsdeath functions. -
death_113_count(): generate death counts for the CDC’s 113 Selected Causes of Death (PLUS COVID-19) -
death_130_count(): generate death counts for the CDC’s 130 Selected Causes of infant Death (PLUS COVID-19) -
death_injury_matrix_count(): generate counts of external cause (a.k.a., injury related) deaths by intent and mechanism -
death_multicause_count(): generate death counts needing BOTH underlying and contributing causes -
death_other_count(): generate counts for select causes of death that are not included indeath_113_count(),death_130_count(), &death_injury_matrix_count(), but may be of interest for public health analyses -
life_table_prep(): prepare dataset for use with thelife_table()function -
life_table(): generate a standard life table, where the first row is the life expectancy at birth (a.k.a. ‘expectation of life’)
All of these functions have detailed help files that are accessible by
typing ?function_name, e.g., ?death_113_count. Some examples for how
to use these functions are given below.
A few quick notes before we begin …
-
death_113_count(),death_130_count(),death_injury_matrix_count(),death_multicause_count()&death_other_count()only work with ICD-10 cause of death codes (i.e., those used since 1999). - If you want to create age-adjusted rates, we recommend you read the age_standardize and calculating_rates_with_rads vignettes after reading through this one.
- To perform a leading causes of death analysis, please follow the Six Step Process on the wiki
rm(list=ls())
library(rads)
library(rads.data) # installed automatically when you installed rads
library(data.table)For this wiki, we will use a prepared synthetic dataset
(rads.data::synthetic_death). However, the tools are generalized and
designed to be usable with any well formatted table of death data.
deaths <- rads.data::synthetic_death
names(deaths) [1] "chi_age" "date_of_death" "date_of_birth"
[4] "chi_geo_kc" "temperament" "underlying_cod_code"
[7] "record_axis_code_1" "record_axis_code_2" "record_axis_code_3"
[10] "record_axis_code_4" "record_axis_code_5" "record_axis_code_6"
[13] "record_axis_code_7" "record_axis_code_8" "record_axis_code_9"
[16] "record_axis_code_10" "record_axis_code_11" "record_axis_code_12"
[19] "record_axis_code_13" "record_axis_code_14" "record_axis_code_15"
[22] "record_axis_code_16" "record_axis_code_17" "record_axis_code_18"
[25] "record_axis_code_19" "record_axis_code_20" "creation_date"
summary(deaths$chi_age) Min. 1st Qu. Median Mean 3rd Qu. Max.
0.00 65.00 76.00 73.27 86.00 100.00
summary(deaths$date_of_death) Min. 1st Qu. Median Mean 3rd Qu. Max.
"2019-01-01" "2020-03-27" "2021-06-27" "2021-06-28" "2022-10-01" "2023-12-31"
table(deaths$chi_geo_kc, useNA = 'always')King County <NA>
26892 6711
table(deaths$temperament) Active Calm Moderate
11085 11207 11311
Our synthetic death data has one columns for the underlying cause of
death (underlying_cod_code) and 20 for the contributing causes of
death (record_axis_code_*). It is top coded at age 100, spans from
2019-2023, and has death and birth dates. If your data set has
equivalent columns, you should be able to use all of the death
functions. In addition, the synthetic data has a King County, WA
indicator as well as a categorical ‘temperament’ variable that we will
use to demonstrate stratification below.
death_icd10_clean() takes a single argument:
-
icdcol: the name of a character vector of ICD-10 codes.
The function can be used to clean any arbitrary vector of ICD-10 codes. Notice that it gives a warning, informing you that the codes were cleaned.
icd_codes <- c('G30.9', 'I25.1', 'I250', 'C349', 'U07-1', 'X44')
cleaned_icd_codes <- death_icd10_clean(icd_codes)Warning in death_icd10_clean(icd_codes):
⚠️ There is at least one row where `icdcol` contains a hyphen (-), period (.),
space or some other non alpha-numeric character. These characters have been deleted,
e.g., A85.2 will become A852. This is necessary because rads death functions expect
pure alpha numeric ICD codes.
print(cleaned_icd_codes)[1] "G309" "I251" "I250" "C349" "U071" "X440"
The function can also be used within a data.table. Notice that this time it gives a different warning, informing you that it had to replace one of the values (i.e., ‘3X44’) with NA because it did not appear to be an ICD-10 code.
mydt <- data.table(icd_codes = c('G309', 'I251', 'I250', 'C349', 'U071', '3X44'))
mydt[, cleaned_icd_codes := death_icd10_clean(icd_codes)]Warning in death_icd10_clean(icd_codes):
⚠️ There is/are 1 value(s) in `icdcol` that do not follow the proper
ICD pattern. All ICDs that do not begin with a letter and end with
a numeric have been replaced with NA.
| icd_codes | cleaned_icd_codes |
|---|---|
| G309 | G309 |
| I251 | I251 |
| I250 | I250 |
| C349 | C349 |
| U071 | U071 |
| 3X44 | NA |
death_validate_data() is used to ensure that your dataset is in good
shape for use with the rads::death_*_clean() functions. It takes five
arguments:
-
ph.data: the name of a person level data.table/data.frame of death data with ICD codes -
icdcol: name of the column with the ICD codes of interest. Defaults to"underlying_cod_code", which is used in APDE’s data. -
check_multicause: Do you also want to validate the contributing cause of death columns? Defaults toFALSE, which means validation is limited toicdcol. -
contributing_cols: The stem name of the contributing cause of death columns inph.data. Only used whencheck_multicause = TRUE. The default iscontributing_cols = 'record_axis_code', which means it will validaterecord_axis_code_1,record_axis_code_2, etc. -
verbose: WhenTRUE(default), prints informational messages about validation results. WhenFALSE, only shows warnings and errors.
For many analyses, you will only need to provide the name of your
dataset (ph.data) and the name of the column with the underlying cause
of death ICD-10 code (icdcol). We want to demonstrate the use of the
death_multicause_count() function below, so we will set
check_multicause = TRUE and contributing_cols = "record_axis_code".
If there are issues, it will generate informative errors or warnings.
death_validate_data(
ph.data = deaths,
icdcol = "underlying_cod_code",
check_multicause = TRUE,
contributing_cols = "record_axis_code",
verbose = TRUE
)ℹ Found 20 contributing cause column(s) matching 'record_axis_code_#'.
🙂 Validation passed! Data is ready for use with rads death analysis functions.
If you didn’t see an error or warning or notification, that means your data is ready to go.
death_113_count() allows the user to get death counts following the
CDC’s National Center for Health Statistics (NCHS) National Vital
Statistics System’s (NVSS) list of 113 selected causes of death (see
Table
B).
To review this list, simply type death_113() into your R console. You
can use this information to select information for either the causeids
or cause arguments of death_113_count().
Here is a snapshot of the top 10 rows from death_113()
| causeid | cause.of.death |
|---|---|
| 1 | Salmonella infections |
| 2 | Shigellosis and amebiasis |
| 3 | Certain other intestinal infections |
| 4 | Respiratory tuberculosis |
| 5 | Other tuberculosis |
| 6 | Whooping cough |
| 7 | Scarlet fever and erysipelas |
| 8 | Meningococcal infection |
| 9 | Septicemia |
| 10 | Syphilis |
death_113_count() takes eight potential arguments:
-
ph.data: the name of a person level data.table/data.frame of death data with ICD codes. -
causeids: specifies the causeid(s) for NCHS 113 Causes of Death (1:113). -
cause: a character vector specifying the causes of death of interest. When specified, it is used in lieu of thecauseids. It is case insensitive and matches partial strings. -
icdcol: name of the column with the ICD codes of interest. Defaults to"underlying_cod_code", which is used in APDE’s data. -
kingco: logical (T|F) specifying whether to limit the analysis to King County. -
group_by: identifies the variables by which you want to group (a.k.a., stratify) the results. -
ypll_age: The age in years (an integer) used for calculating Years of Potential Life Lost. -
death_age_col: Name of the age column used ifypll_ageis specified.
Please refer to the help file for more details.
Count deaths due to COVID-19 or viral hepatitis
deaths.20 <- deaths[between(date_of_death, as.Date('2020-01-01'), as.Date('2020-12-31'))]
dt1 <- death_113_count(ph.data = deaths.20,
cause = 'viral hep|covid') | cause.of.death | causeid | deaths |
|---|---|---|
| All causes | NA | 5,450 |
| COVID-19 (U07.1) | NA | 61 |
| Viral hepatitis | 14 | 13 |
Glancing at the table above, you’ll see that you have the two causes of death of interest, PLUS the total of death from any cause (‘All causes’).
We could have specified ‘Viral hepatitis’ using causeids rather than
the cause text string for the same result. Also, we really can’t
specify COVID-19. Since COVID-19 is not on the official 113 causes of
death list, it does not have a code. It is however returned
automatically by this function.
dt1.alt <- death_113_count(ph.data = deaths.20,
causeids = 14)| cause.of.death | causeid | deaths |
|---|---|---|
| All causes | NA | 5,450 |
| COVID-19 (U07.1) | NA | 61 |
| Viral hepatitis | 14 | 13 |
First, let’s subset to the 2019 & 2020 data …
deaths.19_20 <- deaths[between(date_of_death, as.Date('2019-01-01'), as.Date('2020-12-31'))]
deaths.19_20[, year := year(date_of_death)]Now, let’s use group_by to get the 113 cause of death counts by year
dt113_19_20 <- death_113_count(ph.data = deaths.19_20,
group_by = 'year')Finally, let’s select the top five causes of death by year using data.table
dt113_19_20[cause.of.death != 'All causes',
rank := frank(-deaths),
by = 'year']
dt113_19_20 <- dt113_19_20[rank <= 5 ]
setorder(dt113_19_20, year, rank)| cause.of.death | causeid | deaths | year | rank |
|---|---|---|---|---|
| All other diseases (Residual) | 95 | 786 | 2019 | 1 |
| All other forms of chronic ischemic heart disease | 55 | 284 | 2019 | 2 |
| Alzheimer’s disease | 48 | 271 | 2019 | 3 |
| Cerebrovascular diseases | 61 | 270 | 2019 | 4 |
| Accidental poisoning and exposure to noxious substances | 103 | 268 | 2019 | 5 |
| All other diseases (Residual) | 95 | 731 | 2020 | 1 |
| Cerebrovascular diseases | 61 | 293 | 2020 | 2 |
| Alzheimer’s disease | 48 | 292 | 2020 | 3 |
| All other forms of chronic ischemic heart disease | 55 | 281 | 2020 | 4 |
| All other forms of heart disease | 59 | 233 | 2020 | 5 |
Note! Calculating the leading causes of death that we report publicly is more complicated. Please refer to the wiki and CHI repository README for details.
example #3: Calculating years of potential life lost due to COVID-19 in 2020, assuming age of death at 65 as the standard
First, identify deaths due to COVID-19. Remember COVID-19 is not one of the official 113 causes of death, so let’s arbitrarily get causeid #1 (Salmonella infections), knowing that it will also give us COVID-19.
dt3 <- death_113_count(ph.data = deaths.20,
causeids = 1,
kingco = FALSE,
death_age_col = 'chi_age',
ypll_age = 65)
dt3 <- dt3[cause.of.death == 'COVID-19 (U07.1)'] # limit output to COVID-19| cause.of.death | causeid | deaths | ypll_65 |
|---|---|---|---|
| COVID-19 (U07.1) | NA | 83 | 26 |
The table above tells us that, if everyone who died from COVID-19 in 2020 had lived to at least age 65, they would have lived a total of 26 additional years.
death_130() and death_130_count() are used for the NCHS 130
Selected Causes of Infant Death (Table
C).
They work in exactly the same way as death_113() and
death_113_count() and will therefore not be described in detail.
death_injury_matrix_count() allows the user to get injury related
death counts by intent and mechanism. To review a table of all available
combinations of mechanism and intent, simply type
death_injury_matrix() into your R console. Here are the first six
lines …
mech.n.intent <- death_injury_matrix()[1:6]| mechanism | intent |
|---|---|
| All injury | Unintentional |
| All injury | Suicide |
| All injury | Homicide |
| All injury | Undetermined |
| All injury | Legal intervention/war |
| Cut/pierce | Unintentional |
death_injury_matrix_count() takes eight potential arguments:
-
ph.data: the name of a person level data.table/data.frame of death data with ICD codes -
intent: specifies the intent(s) of interest as per options available indeath_injury_matrix().'none'will ignore intent and return ‘Any intent’.'\*'is a wildcard for all possible intents. -
mechanism: specifies the mechanism(s) of interest as per options available indeath_injury_matrix.'none'will ignore mechanism and return ‘Any mechanism’.'\*'is a wildcard for all possible mechanisms. -
icdcol: name of the column with the ICD codes of interest. Defaults to"underlying_cod_code", which is used in APDE’s data. -
kingco: logical (T|F) specifying whether to limit the analysis to King County. -
group_by: identifies the variables by which you want to group (a.k.a., stratify) the results. -
ypll_age: The age in years (an integer) used for calculating Years of Potential Life Lost. -
death_age_col: Name of the age column used ifypll_ageis specified.
Please refer to the help file for more details.
example #4: 2019-2020 King County injury related deaths (every combination of intent and mechanism), stratified by temperament
Run death_injury_matrix_count() and show the six random rows
dt4 <- death_injury_matrix_count(ph.data = deaths.19_20,
intent = "*",
mechanism = "*",
kingco = FALSE,
group_by = 'temperament')| mechanism | intent | deaths | temperament |
|---|---|---|---|
| All injury | Unintentional | 426 | Active |
| All injury | Unintentional | 374 | Calm |
| All injury | Unintentional | 420 | Moderate |
| Poisoning | Unintentional | 230 | Active |
| Poisoning | Unintentional | 187 | Calm |
| Poisoning | Unintentional | 220 | Moderate |
What happens if you set both intent & mechanism to “none”? The function assumes you want the total injury related deaths (without regard to intent or mechanism).
dt4.alt <- death_injury_matrix_count(ph.data = deaths.19_20,
intent = "none",
mechanism = "none",
kingco = FALSE,
group_by = 'temperament')| mechanism | intent | deaths | temperament |
|---|---|---|---|
| Any mechanism | Any intent | 525 | Active |
| Any mechanism | Any intent | 493 | Calm |
| Any mechanism | Any intent | 537 | Moderate |
example #5: 2019-2023 King County homicides (intent) by firearms (mechanism), stratified by temperament
Run death_injury_matrix_count
deaths.19_23 <- deaths[between(date_of_death, as.Date('2019-01-01'), as.Date('2023-12-31'))]
deaths.19_23[, year := year(date_of_death)]
dt5 <- death_injury_matrix_count(ph.data = deaths.19_23,
intent = "homicide",
mechanism = "firearm",
kingco = FALSE,
group_by = 'temperament')| mechanism | intent | deaths | temperament |
|---|---|---|---|
| Firearm | Homicide | 42 | Active |
| Firearm | Homicide | 49 | Calm |
| Firearm | Homicide | 53 | Moderate |
Run death_injury_matrix_count
dt6 <- death_injury_matrix_count(ph.data = deaths.19_23,
intent = "homicide",
mechanism = "firearm",
kingco = FALSE,
death_age_col = 'chi_age',
ypll_age = 65)| mechanism | intent | deaths | ypll_65 |
|---|---|---|---|
| Firearm | Homicide | 144 | 4,311 |
death_multicause_count() allows the user to get counts causes of death
requiring BOTH underlying AND contributing causes. To view
available analytic ready multicause death categories, simply type
death_multicause(). If you want to add more causes of death to this
list, please submit a GitHub
issue.
In the meantime the function will allow you to specify the underlying
cause of death and contributing cause of death ICD-10 of interest.
death_multicause()| cause_name | description |
|---|---|
| Opioid | Requires any of 160 underlying cause codes AND any of 6 contributing cause codes |
death_multicause_count() takes eleven potential arguments:
-
ph.data: the name of a person level data.table/data.frame of death data with ICD codes, with at least one column of ICD10 underlying cause codes and columns for contributing cause codes. -
cause_name: a character vector specifying the multicause death definition from the reference table. For example,cause_name = "Opioid". To see available options, usedeath_multicause(). -
underlying_codes: a character vector of ICD10 codes that must appear in the underlying cause of death. Only used ifcause_name = NULL. For example,c("X40", "X41", "X42"). -
contributing_codes: a character vector of ICD10 codes that must appear in the contributing causes of death. Only used ifcause_name = NULL. For example,c("T400", "T401"). -
icdcol: name of the column with the underlying cause of death ICD codes. Defaults to"underlying_cod_code", which is used in APDE’s data. -
contributing_cols: a character vector specifying the stem of the column names containing contributing cause codes. The function expects columns named with this stem followed by numbers 1–20. The default,"record_axis_code", leads the function to expect columns named'record_axis_code_1','record_axis_code_2', …'record_axis_code_20'. -
contributing_logic: a character vector specifying whether"ANY"(default) or"ALL"of thecontributing_codesmust be present. -
kingco: logical (T|F) specifying whether to limit the analysis to King County. -
group_by: identifies the variables by which you want to group (a.k.a., stratify) the results. -
ypll_age: The age in years (an integer) used for calculating Years of Potential Life Lost. -
death_age_col: Name of the age column used ifypll_ageis specified.
Please refer to the help file for more details.
dt7 <- death_multicause_count(ph.data = deaths.19_23,
cause_name = "Opioid",
kingco = FALSE,
group_by = "temperament")
dt7 <- dt7[cause.of.death != 'All causes']| cause.of.death | deaths | temperament |
|---|---|---|
| Opioid | 466 | Active |
| Opioid | 446 | Calm |
| Opioid | 449 | Moderate |
death_other_count() allows the user to get death counts for cause of
death that are NOT included in death_113_count(), death_130_count(),
and death_injury_matrix_count(), but that are still of general
interest in public health analyses. To review a list of all available
‘other’ causes of death, simply type death_other() into your R
console. If you want to add additional causes of death to this list,
please submit a GitHub
issue.
death_other() [1] "Alcohol_Death" "CO_Death"
[3] "Cancer" "Chronic liver disease and cirrhosis"
[5] "Chronic lower respiratory disease" "Drug-induced"
[7] "Drug-overdose" "Drug_Death"
[9] "Heart disease" "HeatStress_Death"
[11] "Influenza/pneumonia" "Opioid_Death"
death_other_count() takes seven potential arguments:
-
ph.data: the name of a person level data.table/data.frame of death data with ICD codes -
cause: a character vector specifying the cause(s) of death of interest taken from the list provided bydeath_other(). It is case insensitive and matches partial strings. -
icdcol: name of the column with the ICD codes of interest. Defaults to"underlying_cod_code", which is used in APDE’s data. -
kingco: logical (T|F) specifying whether to limit the analysis to King County. -
group_by: identifies the variables by which you want to group (a.k.a., stratify) the results. -
ypll_age: The age in years (an integer) used for calculating Years of Potential Life Lost. -
death_age_col: Name of the age column used ifypll_ageis specified.
Please refer to the help file for more details.
dt8 <- death_other_count(ph.data = deaths.19_23,
cause = "pneumonia",
kingco = FALSE,
group_by = "year")
dt8 <- dt8[cause.of.death != 'All causes']
setorder(dt8, year, cause.of.death)| cause.of.death | deaths | year |
|---|---|---|
| Influenza/pneumonia | 76 | 2019 |
| Influenza/pneumonia | 75 | 2020 |
| Influenza/pneumonia | 75 | 2021 |
| Influenza/pneumonia | 68 | 2022 |
| Influenza/pneumonia | 84 | 2023 |
Run death_other_count
deaths.21 <- deaths[between(date_of_death, as.Date('2021-01-01'), as.Date('2021-12-31'))]
dt9 <- death_other_count(ph.data = deaths.21,
cause = "cancer|heart",
kingco = FALSE,
ypll_age = 65)| cause.of.death | deaths | ypll_65 |
|---|---|---|
| All causes | 6,680 | 30,146 |
| Cancer | 1,321 | 3,242 |
| Heart disease | 1,268 | 2,396 |
life_table() generates a standard life table, where the first row is
the life expectancy (a.k.a. ‘expectation of life’) at birth. Since it
needs aggregate death data, you are strongly encouraged to preprocess
the death data with life_table_prep(). A simple example of how to
use life_table_prep() is embedded below.
life_table() takes seven potential arguments:
-
ph.data: the name of data.table/data.frame with aggregated deaths and corresponding populations, as well as the age interval and the average fraction of years lived in the interval by those who die in the interval. -
myages: the name of a column inph.datawith the age intervals used for the life table calculations (e.g., c(‘0-1’, ‘1-5’, … ‘85+’)). -
mydeaths: the name of a numeric column inph.datawith the total deaths for the given age interval in the given year. -
mypops: the name of a numeric column inph.datawith the total population corresponding tomydeaths. -
myprops: the name of a numeric column inph.datawith the average proportion of the interval lived by those who died in the interval. -
group_by: identifies the variables by which you want to group (a.k.a., stratify) the results. -
ci: the confidence interval, must be [0, 1]. Default is 0.95
Please refer to the help file for more details.
example #10: Get life expectancy at birth for King County residents born 2019-2023, stratified by year
Use life_table_prep() to aggregate the age interval specific count of
deaths and the average fraction of the interval lived by those who died
in that interval, stratified by sex. Note, by default
life_table_prep() uses the standard age intervals used by the CDC and
WA DOH. These intervals can easily be customized if desired. Here we
show just the top six rows so you can see the data structure.
dt10 = life_table_prep(ph.data = deaths.19_23,
dobvar = "date_of_birth",
dodvar = "date_of_death",
group_by = 'year')| ages | year | deaths | fraction |
|---|---|---|---|
| 0-1 | 2019 | 38 | 0.2505768 |
| 0-1 | 2020 | 41 | 0.2585956 |
| 0-1 | 2021 | 47 | 0.2972023 |
| 0-1 | 2022 | 39 | 0.2610461 |
| 0-1 | 2023 | 43 | 0.1856481 |
| 1-5 | 2019 | 10 | 0.2321609 |
Filter/delete rows with missing ages because they would not have a corresponding population.
dt10 <- dt10[!is.na(ages)]The death data is now ready for life_table, but we still need to merge
on the corresponding populations. Let’s start by getting the raw
population for the same time period (2019–2023) by year and age.
pop <- apde.data::population(kingco = T,
years = 2019:2023,
group_by = c('years', 'ages'))
pop <- pop[, .(year, age, pop)]| year | age | pop |
|---|---|---|
| 2020 | 0 | 24123.00 |
| 2023 | 0 | 22692.62 |
| 2021 | 0 | 23057.35 |
| 2019 | 0 | 24079.99 |
| 2022 | 0 | 23426.97 |
| 2020 | 1 | 24203.00 |
Now we need to aggregate the population data to use the same age intervals as the death data.
my.cuts <- c(0, 1, 5, 10, 15, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85)
pop[, ages := cut(age, my.cuts, right = F)] # create age intervals
pop[, ages := gsub("\\[|\\]|\\)", "", ages)] # tidy
pop[, ages := gsub("\\,", "-", ages)] #tidy
pop[age >= max(my.cuts), ages := paste0(max(my.cuts), "+")] # tidy
pop <- pop[, .(pop = sum(pop)), .(year, ages)] #tidy
pop[, year := as.integer(year)]| year | ages | pop |
|---|---|---|
| 2020 | 0-1 | 24123.00 |
| 2023 | 0-1 | 22692.62 |
| 2021 | 0-1 | 23057.35 |
| 2019 | 0-1 | 24079.99 |
| 2022 | 0-1 | 23426.97 |
| 2020 | 1-5 | 98134.00 |
Merge the properly formatted death and population data together.
dt10 <- merge(dt10,
pop,
by = c('year', 'ages'),
all = T)| year | ages | deaths | fraction | pop |
|---|---|---|---|---|
| 2019 | 0-1 | 38 | 0.2505768 | 24079.99 |
| 2019 | 1-5 | 10 | 0.2321609 | 97540.98 |
| 2019 | 10-15 | 7 | 0.4327710 | 127871.99 |
| 2019 | 15-18 | 11 | 0.4504981 | 74293.00 |
| 2019 | 18-20 | 13 | 0.2869687 | 50366.98 |
| 2019 | 20-25 | 39 | 0.4432063 | 143035.94 |
Run life_table() function to create life tables by year.
dt10.lifetable <- life_table(ph.data = dt10,
group_by = 'year')Display the first row of the life table for each year, which is for
children aged 0-1. The ex column is the expectation of life, which for
0-1 years olds is life expectancy at birth. To see a detailed key of
what all the columns mean, type ?life_table in your R console and read
the ‘Details’ section.
dt10.lifetable[ages == '0-1',]| year | fraction | ages | pop | deaths | mx | qx | lx | dx | ax | Lx | Tx | ex | ex_lower | ex_upper | ex_se |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2019 | 0.2505768 | 0-1 | 24079.99 | 38 | 0.00158 | 0.00158 | 1e+05 | 158 | 0.25 | 99882 | 9367681 | 93.68 | 93.44 | 93.92 | 0.12298 |
| 2020 | 0.2585956 | 0-1 | 24123.00 | 41 | 0.00170 | 0.00170 | 1e+05 | 170 | 0.26 | 99874 | 9395547 | 93.96 | 93.72 | 94.19 | 0.11980 |
| 2021 | 0.2972023 | 0-1 | 23057.35 | 47 | 0.00204 | 0.00204 | 1e+05 | 204 | 0.30 | 99857 | 9419372 | 94.19 | 93.96 | 94.43 | 0.11892 |
| 2022 | 0.2610461 | 0-1 | 23426.97 | 39 | 0.00166 | 0.00166 | 1e+05 | 166 | 0.26 | 99877 | 9416895 | 94.17 | 93.94 | 94.39 | 0.11516 |
| 2023 | 0.1856481 | 0-1 | 22692.62 | 43 | 0.00189 | 0.00189 | 1e+05 | 189 | 0.19 | 99846 | 9480568 | 94.81 | 94.58 | 95.03 | 0.11497 |
We know this was a lot to process. The good news is that this vignette isn’t going anywhere. If you remember (a) that this vignette exists and (b) where to find it, you’ll be in good shape to take on standard mortality analyses in the future.
If you’ve read through this vignette and the corresponding help files and are still confused, please feel free to reach out for assistance. You may have found a bug, who knows? Good luck!
– Updated February 27, 2026 (rads v1.5.5)