Skip to contents

Takes a text string and searches within the package data for a country code in the context of valid API country codes.

Usage

ots_country_code(countryname = NULL)

Arguments

countryname

A text string such as "Chile", "CHILE" or "CHL".

Value

A single character if there is a exact match (e.g. ots_country_code("Chile")) or a tibble in case of multiple matches (e.g. ots_country_code("Germany"))

Examples

ots_country_code("Chile ")
#>    country_iso country_name_english country_fullname_english continent_id
#>         <char>               <char>                   <char>        <int>
#> 1:         chl                Chile                    Chile            5
#>    continent_name_english
#>                    <char>
#> 1:               Americas
ots_country_code("america")
#>    country_iso country_name_english
#>         <char>               <char>
#> 1:         usa                  USA
#>                                                       country_fullname_english
#>                                                                         <char>
#> 1: USA, Puerto Rico and US Virgin Islands (excludes Virgin Islands until 1981)
#>    continent_id continent_name_english
#>           <int>                 <char>
#> 1:            5               Americas
ots_country_code("UNITED  STATES")
#> Empty data.table (0 rows and 5 cols): country_iso,country_name_english,country_fullname_english,continent_id,continent_name_english
ots_country_code(" united_")
#>    country_iso                 country_name_english
#>         <char>                               <char>
#> 1:         tza              United Rep. of Tanzania
#> 2:         umi United States Minor Outlying Islands
#> 3:         are                 United Arab Emirates
#> 4:         gbr                       United Kingdom
#>                country_fullname_english continent_id continent_name_english
#>                                  <char>        <int>                 <char>
#> 1:              United Rep. of Tanzania            3                 Africa
#> 2: United States Minor Outlying Islands            5               Americas
#> 3:                 United Arab Emirates            1                   Asia
#> 4:                       United Kingdom            2                 Europe