Get information about countriesSource:
This function is an interface for REST Countries API. It allows to request and download information about countries, such as: currency, capital city, language spoken, flag, neighbouring countries, and much more. NOTE: Internet access is needed to download information from the API.
country_info( countries = NULL, fields = NULL, fuzzy_match = TRUE, match_info = FALSE, collapse = TRUE )
A vector of countries for which we wish to download information. The function also supports fuzzy matching capabilities to facilitate querying. Information is only returned for the 249 countries in the ISO standard
Logical value indicating whether to allow fuzzy matching of country names. Default is
Logical value indicating whether to return information on country names matched to each input in
TRUE, two additional columns will be added to the output (
is_country). Default is
Logical value indicating whether to collapse multiple columns relating to a same field together. Default is
TRUE. For some specific fields (currencies, languages, names), multiple columns will be returned. This happens because countries can take multiple values for these fields. For example,
country_info("Switzerland", "languages", collapse = FALSE)will return 4 columns for the field languages. When
collapse = TRUE, these four columns will be collapsed into one string, with values separated by semicolons.
Returns the requested information about the countries in a table. The rows of the table correspond to entries in
countries, columns correspond to requested
# The example below queries information on the currency used in Brazil, US and France: info <- country_info(countries = "Brazil", fields = "capital") # data for multiple countries can be requested info <- country_info(countries = c("Brazil", "USA", "FR"), fields = "capital") #' # Data can be returned for all countries by leaving - countries - empty info <- country_info(fields = "capital") # All available fields can be requested by leaving fields empty info <- country_info(countries = c("Brazil", "USA", "FR")) # All information for all countries can be downloaded by leaving both arguments empty info <- country_info()