====== Country codes ====== March 2018 ===== ISO country codes ===== Different country codes can be obtained at: http://www.nationsonline.org/oneworld/country_code_list.htm We can use selected country code for combining world countries data using it as keys. > setwd("C:/Users/batagelj/Downloads/data/CIA") > Europe <- c("AL", "AD", "AM", "AT", "BY", "BE", "BA", "BG", "CH", "CY", + "CZ", "DE", "DK", "EE", "ES", "FO", "FI", "FR", "GB", "GE", "GI", + "GR", "HU", "HR", "IE", "IS", "IT", "LT", "LU", "LV", "MD", "MC", + "MK", "MT", "NO", "NL", "PL", "PT", "RO", "RU", "SE", "SI", "SK", + "SM", "TR", "UA", "VA", "XK") > fmt <- c(rep("character",3),"integer") > C <- read.csv("CountryCodes.txt",sep="\t",skip=1,header=TRUE,colClasses=fmt) > str(C) 'data.frame': 247 obs. of 4 variables: $ Country : chr "Afghanistan" "Aland Islands" "Albania" "Algeria" ... $ ISOalpha2 : chr "AF" "AX" "AL" "DZ" ... $ ISOalpha3 : chr "AFG" "ALA" "ALB" "DZA" ... $ ISOnumeric: int 4 248 8 12 16 20 24 660 10 28 ... > e <- match(Europe,C$ISOalpha2) > e [1] 3 6 12 15 21 22 28 35 215 60 61 84 62 71 208 74 76 77 234 [20] 83 86 87 101 58 107 102 110 129 130 123 145 146 131 137 166 156 177 178 [39] 182 183 214 202 201 193 227 232 99 NA [[notes:da:cia|CIA World Factbook]]