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")

Arguments

nLx

numeric. either NULL or a numeric vector of lifetable exposure. If it's the second then we just pass it back.

location

vector. UN Pop Div LocName or LocID

gender

character. "male", "female", or "both"

nLxDatesIn

numeric. Vector of three decimal dates produced by (or passed through) basepop_five()

method

character. Could be "linear", "exponential", or "power"

Value

numeric matrix of nLx with length(nLxDatesIn) and abridged ages in rows.

Examples

# life expectancy calculated from Lx downloaded from WPP19. Using names or codes. Lxs_name <- downloadnLx(nLx=NULL, location = "Argentina", gender = "both", nLxDatesIn = 1950:2030)
#> Downloading nLx data for Argentina, years 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, gender both #> Careful, extrapolating beyond range 1950-2025
Lxs_code <- downloadnLx(nLx=NULL, location = "32", gender = "both", nLxDatesIn = 1950:2030)
#> Downloading nLx data for 32, years 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, gender both #> Careful, extrapolating beyond range 1950-2025
if (FALSE) { plot(1950:2030, as.numeric(colSums(Lxs_name)), xlab = "Year", ylab="e0") lines(1950:2030, as.numeric(colSums(Lxs_code))) } # life expectancy for different countries Lxs_countries <- downloadnLx(nLx=NULL, location = c("Argentina","Brazil","Uruguay"), gender = "both", nLxDatesIn = 1950:2025)
#> Downloading nLx data for Argentina, years 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, gender both #> Downloading nLx data for Brazil, years 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, gender both #> Downloading nLx data for Uruguay, years 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, gender both
if (FALSE) { 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) }