
Get Japan's Life Expectancy at Birth from World Bank
Source:R/get_japan_life_expectancy.R
get_japan_life_expectancy.RdRetrieves Japan's life expectancy at birth (in years) for the years 2010 to 2022
using the World Bank Open Data API. The indicator used is SP.DYN.LE00.IN.
Source
World Bank Open Data API: https://data.worldbank.org/indicator/SP.DYN.LE00.IN
Value
A tibble with the following columns, or NULL if the API is unavailable:
indicator: Indicator name (e.g., "Life expectancy at birth, total (years)")country: Country name ("Japan")year: Year of the data (integer)value: Life expectancy value in numeric form (years)
Details
The function sends a GET request to the World Bank API.
If the API request fails or returns an error status code, the function returns NULL with an informative message.
Examples
# \donttest{
# Requires internet connection
result <- get_japan_life_expectancy()
if (!is.null(result)) {
print(result)
}
#> # A tibble: 13 × 4
#> indicator country year value
#> <chr> <chr> <int> <dbl>
#> 1 Life expectancy at birth, total (years) Japan 2022 84.0
#> 2 Life expectancy at birth, total (years) Japan 2021 84.4
#> 3 Life expectancy at birth, total (years) Japan 2020 84.6
#> 4 Life expectancy at birth, total (years) Japan 2019 84.4
#> 5 Life expectancy at birth, total (years) Japan 2018 84.2
#> 6 Life expectancy at birth, total (years) Japan 2017 84.1
#> 7 Life expectancy at birth, total (years) Japan 2016 84.0
#> 8 Life expectancy at birth, total (years) Japan 2015 83.8
#> 9 Life expectancy at birth, total (years) Japan 2014 83.6
#> 10 Life expectancy at birth, total (years) Japan 2013 83.3
#> 11 Life expectancy at birth, total (years) Japan 2012 83.1
#> 12 Life expectancy at birth, total (years) Japan 2011 82.6
#> 13 Life expectancy at birth, total (years) Japan 2010 82.8
# }