Compute life expectancy from age-specific mortality rates
Source:R/life_expectancy.R
life_expectancy.RdReturns remaining life expectancy at a given age (0 by default).
Arguments
- .data
A vital object including an age variable and a variable containing mortality rates.
- from_age
Age at which life expectancy to be calculated. Either a scalar or a vector of ages.
- mortality
Variable in
.datacontaining Mortality rates (mx). If omitted, the variable with namemx,MortalityorRatewill be used (not case sensitive).
References
Chiang CL. (1984) The life table and its applications. Robert E Krieger Publishing Company: Malabar.
Keyfitz, N, and Caswell, H. (2005) Applied Mathematical Demography, Springer-Verlag: New York.
Preston, S.H., Heuveline, P., and Guillot, M. (2001) Demography: measuring and modeling population processes. Blackwell
Examples
# Compute Norwegian life expectancy for females over time
norway_mortality |>
dplyr::filter(Sex == "Female") |>
life_expectancy()
#> # A vital: 124 x 4 [1Y]
#> # Key: Age x Sex [1 x 1]
#> Year Age Sex ex
#> <int> <int> <chr> <dbl>
#> 1 1900 0 Female 55.2
#> 2 1901 0 Female 56.4
#> 3 1902 0 Female 58.0
#> 4 1903 0 Female 56.5
#> 5 1904 0 Female 57.3
#> 6 1905 0 Female 56.2
#> 7 1906 0 Female 58.1
#> 8 1907 0 Female 57.9
#> 9 1908 0 Female 57.6
#> 10 1909 0 Female 58.9
#> # ℹ 114 more rows