| is_country {countries} | R Documentation |
Tests whether a string is a country name
Description
This function checks whether the string is a country name. It supports different languages and naming conventions.
The function returns TRUE if it relates to one of the 249 countries currently in the ISO standard 3166.
Alternatively, the argument check_for allows to narrow down the test to a subset of countries.
Fuzzy matching can be used to allow a small margin of error in the string.
Usage
is_country(x, check_for = NULL, fuzzy_match = FALSE)
Arguments
x |
A character vector to be tested (also supports UN/ISO country codes) |
check_for |
A vector of country names to narrow down testing. The function will return |
fuzzy_match |
A logical value indicating whether to tolerate small discrepancies in the country name matching. The default and fastest option is |
Value
Returns a logical vector indicating whether the string is a country name
See Also
match_table, country_name, find_countrycol
Examples
#Detect strings that are country names
is_country(x=c("ITA","Estados Unidos","Estado Unidos","bungalow","dog",542), fuzzy_match=FALSE)
is_country(x=c("ITA","Estados Unidos","Estado Unidos","bungalow","dog",542), fuzzy_match=TRUE)
#Checking for a specific subset of countries
is_country(x=c("Ceylon","LKA","Indonesia","Inde"), check_for=c("India","Sri Lanka"))