Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

guess_field

Guess the code/name of a vector


Description

Users sometimes do not know what kind of code or field their data contain. This function tries to guess by comparing the similarity between a user-supplied vector and all the codes included in the 'countrycode' dictionary.

Usage

guess_field(codes, min_similarity = 80)

Arguments

codes

a vector of country codes or country names

min_similarity

the function returns all field names where over than 'min_similarity' 'countrycode' dictionary.

Examples

# Guess ISO codes
guess_field(c('DZA', 'CAN', 'DEU'))

# Guess country names
guess_field(c('Guinea','Iran','Russia','North Korea',rep('Ivory Coast',50),'Scotland'))

countrycode

Convert Country Names and Country Codes

v1.2.0
GPL-3
Authors
Vincent Arel-Bundock [aut, cre] (<https://orcid.org/0000-0003-2042-7063>), CJ Yetman [ctb] (<https://orcid.org/0000-0001-5099-9500>), Nils Enevoldsen [ctb] (<https://orcid.org/0000-0001-7195-4117>)
Initial release
2020-05-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.