Created
June 23, 2019 15:03
-
-
Save geotheory/5b315cfacf5b8e071ced4a1908a85e7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(tidyverse) | |
require(countrycode) | |
closest_field = function(x){ | |
map_dbl(codelist, ~ 100 * sum(x %in% .x) / length(x)) %>% as.data.frame %>% | |
tibble::rownames_to_column() %>% `names<-`(c('field','pc_match')) %>% as_tibble() %>% | |
arrange(-pc_match) | |
} | |
closest_field(c('CM','AL','PA','MK','HA','CO','ZI','KU','TH','FI')) | |
#> # A tibble: 677 x 2 | |
#> field pc_match | |
#> <chr> <dbl> | |
#> 1 fips 100 | |
#> 2 ecb 70 | |
#> 3 eurostat 70 | |
#> 4 genc2c 70 | |
#> 5 iso2c 70 | |
#> 6 wb_api2c 70 | |
#> 7 cldr.name.as 70 | |
#> 8 cldr.name.bem 70 | |
#> 9 cldr.name.bo 70 | |
#> 10 cldr.name.cu 70 | |
#> # … with 667 more rows | |
closest_field(c('Ivory Coast','Guinea','Iran','Russia','North Korea')) | |
#> # A tibble: 677 x 2 | |
#> field pc_match | |
#> <chr> <dbl> | |
#> 1 cow.name 100 | |
#> 2 cldr.variant.en 100 | |
#> 3 country.name.en 80 | |
#> 4 eurostat.name 80 | |
#> 5 p4.name 80 | |
#> 6 wvs.name 80 | |
#> 7 cldr.name.en 80 | |
#> 8 cldr.name.nd 80 | |
#> 9 cldr.name.sn 80 | |
#> 10 cldr.short.en 80 | |
#> # … with 667 more rows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment