Skip to contents

Retrieves Indonesia'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.

Usage

get_indonesia_life_expectancy()

Source

World Bank Open Data API: https://data.worldbank.org/indicator/SP.DYN.LE00.IN

Value

A tibble with the following columns:

  • indicator: Indicator name (e.g., "Life expectancy at birth, total (years)")

  • country: Country name ("Indonesia")

  • year: Year of the data (integer)

  • value: Life expectancy value in numeric form (years)

Returns NULL if the API is unavailable or returns an error.

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.

Note

Requires internet connection. The data is retrieved in real time from the World Bank API.

See also

Examples

# \donttest{
get_indonesia_life_expectancy()
#> # A tibble: 13 × 4
#>    indicator                               country    year value
#>    <chr>                                   <chr>     <int> <dbl>
#>  1 Life expectancy at birth, total (years) Indonesia  2022  70.9
#>  2 Life expectancy at birth, total (years) Indonesia  2021  67.5
#>  3 Life expectancy at birth, total (years) Indonesia  2020  68.8
#>  4 Life expectancy at birth, total (years) Indonesia  2019  70.3
#>  5 Life expectancy at birth, total (years) Indonesia  2018  70.1
#>  6 Life expectancy at birth, total (years) Indonesia  2017  70.0
#>  7 Life expectancy at birth, total (years) Indonesia  2016  69.7
#>  8 Life expectancy at birth, total (years) Indonesia  2015  69.5
#>  9 Life expectancy at birth, total (years) Indonesia  2014  69.3
#> 10 Life expectancy at birth, total (years) Indonesia  2013  69.1
#> 11 Life expectancy at birth, total (years) Indonesia  2012  68.9
#> 12 Life expectancy at birth, total (years) Indonesia  2011  68.6
#> 13 Life expectancy at birth, total (years) Indonesia  2010  68.4
# }