| is_country | R Documentation |
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.
is_country(x, check_for = NULL, fuzzy_match = FALSE)
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 |
Returns a logical vector indicating whether the string is a country name
match_table, country_name, find_countrycol
#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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.