get_countries_by_currency {tidycountries}R Documentation

get_countries_by_currency

Description

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.

Usage

get_countries_by_currency(currency_input, geometry = FALSE)

Arguments

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 FALSE. If TRUE, the function performs a left join with boundary data and returns a spatial sf data frame.

Value

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.

Note

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.

Examples


# 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)


[Package tidycountries version 0.1.0 Index]