country_input_type: Determines whether country input is a country name or...

country_input_typeR Documentation

Determines whether country input is a country name or iso2Code

Description

Determines whether a string is a country name, an iso2Code, or invalid (not a World Bank API country/region)

Usage

country_input_type(country_input, countries_dataframe)

Arguments

country_input

A country/region the user wishes to validate (string) E.g. "Australia".

countries_dataframe

A dataframe containing available iso2Code and country_name (see show_countries()).

Value

A character vector

Examples


## Not run: 
# Assign so as to save on API calls - recommended
countries_dataframe <- show_countries()

  country <- "Australia"
  country_input_type(country, countries_dataframe)
# [1] "country_name"

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

  country <- "something other than a valid country name or iso2Code"
  country_input_type(country, countries_dataframe)
# [1] "invalid"

## End(Not run)

priceR documentation built on Oct. 22, 2023, 1:10 a.m.