Skip to contents

Gives user more control over their lifetable compared to the life_expectancy() function. Allows the user to add in the central death rate and proportion surviving to age x. Allows the user to omit accessory columns which are used to calculate life expectancy.

Usage

lifetable(
  data,
  age,
  pop,
  deaths,
  includeAllSteps = TRUE,
  includeCDR = TRUE,
  includePS = TRUE,
  ...
)

Arguments

data

The mortality dataset, includes an age grouping variable,

age

The age grouping variable, must be categorical

pop

Population of each age group, must be numeric

deaths

The midyear number of deaths at each age group, must be numeric

includeAllSteps

If false, will only include the proportion surviving to age x and life expectancy for age x

includeCDR

If true, will include the central death rate for each age group

includePS

If true, will include the proportion surviving for each age group

...

Other optional grouping variables (can be race, gender, etc.)

Value

Lifetable

Examples

# Running lifetable() and choosing not to include CentralDeathRate and
# ProportionToSurvive (optional columns) in the output dataset

lifetable(mortality2, "age_group", "population", "deaths", FALSE, TRUE, TRUE)
#> # A tibble: 85 × 6
#>    age_group deaths population CentralDeathRate PropToSurvive LifeExpectancy
#>    <chr>      <dbl>      <dbl>            <dbl>         <dbl>          <dbl>
#>  1 < 1 year   23161    3970145         0.00583          1               75.9
#>  2 1 year      1568    3995008         0.000392         0.994           75.3
#>  3 2 years     1046    3992154         0.000262         0.994           74.4
#>  4 3 years      791    3982074         0.000199         0.994           73.4
#>  5 4 years      640    3987656         0.000160         0.993           72.4
#>  6 5 years      546    4032515         0.000135         0.993           71.4
#>  7 6 years      488    4029655         0.000121         0.993           70.4
#>  8 7 years      511    4029991         0.000127         0.993           69.4
#>  9 8 years      483    4159114         0.000116         0.993           68.4
#> 10 9 years      462    4178524         0.000111         0.993           67.4
#> # ℹ 75 more rows