Learn R Programming

priceR (version 0.1.6)

convert_to_iso2Code: Convert any country input into its iso2Code

Description

`convert_to_iso2Code` accepts the type of country input and the country, and returns the relevant iso2Code

Usage

convert_to_iso2Code(country_input_type_string, country, countries_dataframe)

Arguments

country_input_type_string

Either "country_name" or "iso2Code" - use country_input_type(country, countries_dataframe) to determine or assign manually.

country

A country/region name or iso2Code.

countries_dataframe

The output of show_countries()

Value

A character vector containing a valid iso2Code

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# Assign so as to save on API calls (recommended)
countries_dataframe <- show_countries()
country <- "Australia"
country_input_type_string <- country_input_type(country, countries_dataframe)
convert_to_iso2Code(country_input_type_string, country, countries_dataframe)
# [1] "AU"

country <- "AU"
country_input_type_string <- country_input_type(country, countries_dataframe)
convert_to_iso2Code(country_input_type_string, country, countries_dataframe)
# [1] "AU"


# }
# NOT RUN {
# }

Run the code above in your browser using DataLab