guess_field {countrycode}R Documentation

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% of codes are shared between the supplied vector and the 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'))

[Package countrycode version 1.3.0 Index]