Skip to contents

This function retrieves information about geographies (countries and regions) from the World Bank API. It returns a tibble containing various details such as the geography's ID, ISO2 code, name, region information, lending type, capital city, and coordinates.

Usage

wdi_get_geographies(language = "en", per_page = 1000)

Arguments

language

A character string specifying the language for the API response. Defaults to "en" (English). Other supported options include "es" (Spanish), "fr" (French), and others depending on the API.

per_page

An integer specifying the number of records to fetch per request. Defaults to 1000.

Value

A tibble with the following columns:

geography_id

A character string representing the geography's unique identifier.

geography_name

A character string for the name of the geography.

geography_iso2code

A character string for the ISO2 country code.

geography_type

A character string for the type of the geography ("country" or "region").

region_id

A character string representing the region's unique identifier.

region_name

A character string for the name of the region.

region_iso2code

A character string for the ISO2 region code.

admin_region_id

A character string representing the administrative region's unique identifier.

admin_region_name

A character string for the name of the administrative region.

admin_region_iso2code

A character string for the ISO2 code of the administrative region.

income_level_id

A character string representing the geography's income level.

income_level_name

A character string for the name of the income level.

income_level_iso2code

A character string for the ISO2 code of the income level.

lending_type_id

A character string representing the lending type's unique identifier.

lending_type_name

A character string for the name of the lending type.

lending_type_iso2code

A character string for the ISO2 code of the lending type.

capital_city

A character string for the name of the capital city.

longitude

A numeric value for the longitude of the geography.

latitude

A numeric value for the latitude of the geography.

Details

This function sends a request to the World Bank API to retrieve data for all supported geographies in the specified language. The data is then processed into a tidy format and includes information about the country, such as its ISO code, capital city, geographical coordinates, and additional metadata about regions, income levels, and lending types.

Examples

# Download all geographies in English
wdi_get_geographies()
#> # A tibble: 296 × 19
#>    geography_id geography_iso2code geography_type capital_city    geography_name
#>    <chr>        <chr>              <chr>          <chr>           <chr>         
#>  1 ABW          AW                 Country        Oranjestad      Aruba         
#>  2 AFE          ZH                 Region         NA              Africa Easter…
#>  3 AFG          AF                 Country        Kabul           Afghanistan   
#>  4 AFR          A9                 Region         NA              Africa        
#>  5 AFW          ZI                 Region         NA              Africa Wester…
#>  6 AGO          AO                 Country        Luanda          Angola        
#>  7 ALB          AL                 Country        Tirane          Albania       
#>  8 AND          AD                 Country        Andorra la Vel… Andorra       
#>  9 ARB          1A                 Region         NA              Arab World    
#> 10 ARE          AE                 Country        Abu Dhabi       United Arab E…
#> # ℹ 286 more rows
#> # ℹ 14 more variables: region_id <chr>, region_iso2code <chr>,
#> #   region_name <chr>, admin_region_id <chr>, admin_region_iso2code <chr>,
#> #   admin_region_name <chr>, income_level_id <chr>,
#> #   income_level_iso2code <chr>, income_level_name <chr>,
#> #   lending_type_id <chr>, lending_type_iso2code <chr>,
#> #   lending_type_name <chr>, longitude <dbl>, latitude <dbl>

# Download all geographies in Spanish
wdi_get_geographies(language = "zh")
#> # A tibble: 296 × 19
#>    geography_id geography_iso2code geography_type capital_city geography_name  
#>    <chr>        <chr>              <chr>          <chr>        <chr>           
#>  1 ABW          AW                 Country        奥拉涅斯塔德 阿鲁巴          
#>  2 AFE          ZH                 Country        NA           NA              
#>  3 AFG          AF                 Country        喀布尔       阿富汗          
#>  4 AFR          A9                 Country        NA           NA              
#>  5 AFW          ZI                 Country        NA           NA              
#>  6 AGO          AO                 Country        罗安达       安哥拉          
#>  7 ALB          AL                 Country        地拉那       阿尔巴尼亚      
#>  8 AND          AD                 Country        安道尔城     安道尔共和国    
#>  9 ARB          1A                 Country        NA           阿拉伯联盟国家  
#> 10 ARE          AE                 Country        阿布扎比     阿拉伯联合酋长国
#> # ℹ 286 more rows
#> # ℹ 14 more variables: region_id <chr>, region_iso2code <chr>,
#> #   region_name <chr>, admin_region_id <chr>, admin_region_iso2code <chr>,
#> #   admin_region_name <chr>, income_level_id <chr>,
#> #   income_level_iso2code <chr>, income_level_name <chr>,
#> #   lending_type_id <chr>, lending_type_iso2code <chr>,
#> #   lending_type_name <chr>, longitude <dbl>, latitude <dbl>