get_country_info | R Documentation |
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.
get_country_info(country_value, geometry = FALSE)
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 |
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.
The returned data frame includes relevant country details. If geometry = TRUE
, an additional column for geographic boundaries is included.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.