get_countries_by_currency | R Documentation |
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)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.