Skip to contents

Retrieves Colombia's life expectancy at birth (total, years) for the years 2010 to 2022 using the World Bank Open Data API. The indicator used is SP.DYN.LE00.IN.

Usage

get_colombia_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 ("Colombia")

  • year: Year of the data (integer)

  • value: Life expectancy at birth in years

Details

This function sends a GET request to the World Bank API. If the API request fails or returns an error status code, the function returns an empty tibble with the expected structure, instead of NULL, to ensure CRAN compatibility in offline checks.

Note

Requires internet connection for real data.

See also

Examples

# \donttest{
  life_expectancy_data <- get_colombia_life_expectancy()
  head(life_expectancy_data)
#> # A tibble: 6 × 4
#>   indicator                               country   year value
#>   <chr>                                   <chr>    <int> <dbl>
#> 1 Life expectancy at birth, total (years) Colombia  2022  76.5
#> 2 Life expectancy at birth, total (years) Colombia  2021  72.7
#> 3 Life expectancy at birth, total (years) Colombia  2020  74.8
#> 4 Life expectancy at birth, total (years) Colombia  2019  76.8
#> 5 Life expectancy at birth, total (years) Colombia  2018  76.6
#> 6 Life expectancy at birth, total (years) Colombia  2017  76.4
# }