get_country_info {tidycountries}R Documentation

get_country_info

Description

This function retrieves information about a specific country based on its country code (cca2 or cca3) or common name. The function is case-insentive and provides a comprehensive overview of the selected country If "all" is passed as the input, it returns data for all countries. If the input does not match any country, the function returns a list of all available country names.

Usage

get_country_info(country_value, geometry = FALSE)

Arguments

country_value

A character string representing the country code(cca2 or cca3) or common name. The input is case-insensitive. If "all" is passed, the function return data for all countries.

geometry

Logical. If TRUE, includes spatial geometry data for the country (boundaries). Defaults to FALSE. When TRUE, an additional column for geographic boundaries is included.

Value

A data frame with selected country information. If geometry = TRUE, the result includes a geometry column with boundary data, making the returned object ready to be converted to an sf (simple features) data frame for spatial analysis. If the input is "all", it returns data for all countries. If no match is found, a list of all available country names is printed.

Note

The returned data frame includes relevant country details. If geometry = TRUE, an additional column for geographic boundaries is included.

Examples


# Examples usage: Get information for Nigeria
nigeria_info <- get_country_info("Nigeria")
print(nigeria_info)

# Example usage: Get information for a country using it's cca2 code
usa_info <- get_country_info("US")
print(usa_info)


[Package tidycountries version 0.1.0 Index]