Title: | Access and Manipulate Comprehensive Country Level Data in Tidy Format |
---|---|
Description: | A comprehensive and user-friendly interface for accessing, manipulating, and analyzing country-level data from around the world. It allows users to retrieve detailed information on countries, including names, regions, continents, populations, currencies, calling codes, and more, all in a tidy data format. The package is designed to work seamlessly within the 'tidyverse' ecosystem, making it easy to filter, arrange, and visualize country-level data in R. |
Authors: | Dennis Irorere [aut, cre, cph] |
Maintainer: | Dennis Irorere <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-28 11:23:00 UTC |
Source: | CRAN |
This function retrieves a list of countries where a specified currency is used. The function is case-insensitive and matches the currency name or part of the name. The output is ordered alphabetically by country name.
get_countries_by_currency(currency_input, geometry = FALSE)
get_countries_by_currency(currency_input, geometry = FALSE)
currency_input |
A character string representing the currency name or part of the name. The input is case-insensitive. |
geometry |
A logical value indicating whether to include geographic boundary data. Defaults to |
A data frame containing the list of countries that use the specified currency, ordered alphabetically by country name.
The columns include country codes (CCA2 and CCA3), common name, capital, continents, currency name, currency symbol, latitude, and longitude.
If geometry = TRUE
, an additional column for geographic boundaries is included.
The function utilizes the pre-loaded restcountries_data
dataset. Ensure that this dataset is loaded before invoking the function.
The function uses a case-insensitive regular expression to match the currency name, allowing partial matches.
If geometry = TRUE
, the function joins with the world_administrative_boundaries
dataset, which must also be pre-loaded.
# Example usage: Find all countries that use the Euro euro_countries <- get_countries_by_currency("Euro") print(euro_countries) # Example usage: Find all countries that use a currency with "dollar" in its name dollar_countries <- get_countries_by_currency("dollar", geometry = TRUE) print(dollar_countries) # Example usage: Find all countries that use the Yen yen_countries <- get_countries_by_currency("Yen") print(yen_countries)
# Example usage: Find all countries that use the Euro euro_countries <- get_countries_by_currency("Euro") print(euro_countries) # Example usage: Find all countries that use a currency with "dollar" in its name dollar_countries <- get_countries_by_currency("dollar", geometry = TRUE) print(dollar_countries) # Example usage: Find all countries that use the Yen yen_countries <- get_countries_by_currency("Yen") print(yen_countries)
This function retrieves a list of countries based on a specified region, subregion, or continent. The function is case-insensitive and orders the countries alphabetically by their common names. If the input does not match any region, subregion, or continent, the function provides a list of all available regions, subregions, and continents.
get_countries_by_region(country_region_value, geometry = FALSE)
get_countries_by_region(country_region_value, geometry = FALSE)
country_region_value |
A character string representing the region, subregion, or continent. The input is case-insensitive. |
geometry |
Logical. If |
A data frame with information on countries within the specified region, subregion, or continent.
If geometry = TRUE
, the result includes a geometry column with boundary data.
If no match is found, a message lists all available regions, subregions, and continents.
This function returns relevant information on countries in a specified region. When geometry = TRUE
, it returns an sf
object, including spatial data.
# Example usage: Get a list of countries in Africa africa_countries <- get_countries_by_region("Africa") print(africa_countries) # Example usage: Get countries in a specific continent with geometry included western_europe_countries <- get_countries_by_region("Western Europe", geometry = TRUE) print(western_europe_countries) # Example usage: Get a list of countries in the continent of Asia asia_countries <- get_countries_by_region("Asia") print(asia_countries)
# Example usage: Get a list of countries in Africa africa_countries <- get_countries_by_region("Africa") print(africa_countries) # Example usage: Get countries in a specific continent with geometry included western_europe_countries <- get_countries_by_region("Western Europe", geometry = TRUE) print(western_europe_countries) # Example usage: Get a list of countries in the continent of Asia asia_countries <- get_countries_by_region("Asia") print(asia_countries)
This function retrieves information about countries based on a specified calling code or part of it. The input can be a root calling code, suffix, or a full calling code, and the function is case-insensitive.
get_country_by_calling_code(call_code, geometry = FALSE)
get_country_by_calling_code(call_code, geometry = FALSE)
call_code |
A character string representing the calling code, root calling code, or suffix. The input is case-insensitive. |
geometry |
A logical value indicating whether to include geographic boundary data. Defaults to |
A data frame containing the information of countries corresponding to the specified calling code, root, or suffixes.
If geometry = TRUE
, the result will include an additional column for geographic boundaries (as spatial features).
The function utilizes the pre-loaded restcountries_data
dataset. Ensure that this dataset is loaded before invoking the function.
If geometry = TRUE
, the function joins with the world_administrative_boundaries
dataset, which must also be pre-loaded.
# Example usage: Find country information by root calling code us_info <- get_country_by_calling_code("+1") print(us_info) # Example usage: Find country information by calling code suffix and include geometry uk_info <- get_country_by_calling_code("44", geometry = TRUE) print(uk_info) # Example usage: Find country information by full calling code india_info <- get_country_by_calling_code("+91") print(india_info)
# Example usage: Find country information by root calling code us_info <- get_country_by_calling_code("+1") print(us_info) # Example usage: Find country information by calling code suffix and include geometry uk_info <- get_country_by_calling_code("44", geometry = TRUE) print(uk_info) # Example usage: Find country information by full calling code india_info <- get_country_by_calling_code("+91") print(india_info)
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)
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)
# 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)
A dataset containing tidied information about countries from the Restcountries API.
restcountries_tidy_data
restcountries_tidy_data
A data frame with several rows and the following columns:
Top-level domain(s) associated with the country.
Common name of the country.
Official name of the country.
Country code (2-letter).
Country code (3-letter).
FIFA code of the country.
Independence status (TRUE/FALSE).
Country status (e.g., officially assigned).
Whether the country is a UN member (TRUE/FALSE).
Geographic region.
Subregion.
Population of the country.
Capital city of the country.
Latitude of the capital city.
Longitude of the capital city.
Continent(s) the country is part of.
Latitude of the country.
Longitude of the country.
Whether the country is landlocked (TRUE/FALSE).
Countries that share a border.
Total area of the country in square kilometers.
Day the week starts (e.g., Monday).
Timezones applicable to the country.
Root of the country calling code.
Suffixes of the country calling code.
Which side of the road cars drive on.
Google Maps link for the country.
OpenStreetMap link for the country.
URL to PNG image of the country flag.
URL to SVG image of the country flag.
Alternative text for the country flag.
Currencies used in the country.
Languages spoken in the country.
Name of the primary currency used.
Symbol of the primary currency used.
Calling code(s) associated with the country.
This dataset includes a variety of country-level data such as country codes, names, capitals, regions, subregions, continents, currencies, population, geographic coordinates, languages, and more.
Data obtained from the Restcountries Json file and processed for use in this package.
# Load the dataset and view the first few rows data(restcountries_tidy_data) head(restcountries_tidy_data)
# Load the dataset and view the first few rows data(restcountries_tidy_data) head(restcountries_tidy_data)
A dataset containing information about world administrative boundaries.
world_administrative_boundaries
world_administrative_boundaries
A data frame with several rows and the following columns:
Country code (3-letter).
geographic boundaries
This dataset includes country code and the geometries
Data obtained from the World Food Programme (UN agency) processed for use in this package.
# Load the dataset and view the first few rows data(world_administrative_boundaries) head(world_administrative_boundaries)
# Load the dataset and view the first few rows data(world_administrative_boundaries) head(world_administrative_boundaries)