Learn R Programming

priceR (version 1.0.2)

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)

Value

A character vector containing a valid iso2Code

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

Examples

Run this code

if (FALSE) {

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


}

Run the code above in your browser using DataLab