View source: R/utils_downloads.R
downloadnLx | R Documentation |
We extract Lx
from wpp2019
, interpolated to exact dates. Different methods available.
A vector of countries can handle, but with an unique sex. Row names are not indicative of countries.
downloadnLx(nLx, location, gender, nLxDatesIn, method = "linear")
nLx |
numeric. either |
location |
vector. UN Pop Div |
gender |
character. |
nLxDatesIn |
numeric. Vector of three decimal dates produced by (or passed through) |
method |
character. Could be |
numeric matrix of nLx
with length(nLxDatesIn)
and abridged ages in rows.
# life expectancy calculated from Lx downloaded from WPP19. Using names or codes.
Lxs_name <- downloadnLx(nLx=NULL, location = "Argentina",
gender = "both", nLxDatesIn = 1950:2030)
Lxs_code <- downloadnLx(nLx=NULL, location = "32",
gender = "both", nLxDatesIn = 1950:2030)
## Not run:
plot(1950:2030, as.numeric(colSums(Lxs_name)), xlab = "Year", ylab="e0")
lines(1950:2030, as.numeric(colSums(Lxs_code)))
## End(Not run)
# life expectancy for different countries
Lxs_countries <- downloadnLx(nLx=NULL, location = c("Argentina","Brazil","Uruguay"),
gender = "both", nLxDatesIn = 1950:2025)
## Not run:
plot(1950:2025, as.numeric(colSums(Lxs_countries[1:22,])),
t="l", xlab = "Year", ylab="e0", ylim = c(40,80))
lines(1950:2025, as.numeric(colSums(Lxs_countries[23:44,])), col=2)
lines(1950:2025, as.numeric(colSums(Lxs_countries[45:64,])), col=3)
legend("bottomright",c("Argentina","Brazil","Uruguay"),lty=1,col=1:3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.