Skip to contents

Subset to obtain data for countries containing specified characters to search

Usage

countryHas(char, full.list = TRUE)

Arguments

char

character to search for

full.list

whether to return only name of country or full list

Value

country data list matching content from a specified character

See also

countryStartsWith for country search starting with specified characters, and [countryEndsWith()] for countries that end with a specified characters.

Examples

# task 1: get only names of countries that contains with "ER" or "er"
# note that the search in case-insensitive
countryHas("er", full.list = FALSE)
#>  [1] "Algeria"                "Azerbaijan"             "Bosnia and Herzegovina"
#>  [4] "Cape Verde"             "Cameroon"               "Eritrea"               
#>  [7] "Faeroe Islands"         "Germany"                "Liberia"               
#> [10] "Netherlands"            "Niger"                  "Nigeria"               
#> [13] "Peru"                   "Serbia"                 "Sierra Leone"          
#> [16] "Switzerland"           

# task 2: get only names of countries that contains with "LAND" or "lAND" or "land"
countryHas("lAND", full.list = FALSE)
#>  [1] "Faeroe Islands"   "Falkland Islands" "Finland"          "Iceland"         
#>  [5] "Ireland"          "Netherlands"      "New Zealand"      "Poland"          
#>  [9] "Switzerland"      "Thailand"        

# task 3: repeat task 2, but return full list for each country
countryHas("many", full.list = TRUE)
#> $`1`
#>       ID    name currency symbol isocode fractionalunity officiallanguage
#> 69 10069 Germany     Euro      \200     EUR            Cent           German
#>    population2023 callingcode continent capital
#> 69       84432670          49    Europe  Berlin
#>