Rutils/iso3166.r

#------------------------------------------------------------------------------------------#
#     List of all countries, with full name, alternative name, and the iso3166 3-letter    #
# code.                                                                                    #
#------------------------------------------------------------------------------------------#
country.tmp <<- list(
     list( iata = "abw"
         , full = "aruba"                                       
         , alte = "aruba"
         )#end list         
   , list( iata = "aia"
         , full = "anguilla"                                    
         , alte = "anguilla"
         )#end list
   , list( iata = "arg"
         , full = "argentina"                                   
         , alte = "argentina"
         )#end list
   , list( iata = "asc"
         , full = "ascension island"                            
         , alte = "ascension"
         )#end list
   , list( iata = "atg"
         , full = "antigua and barbuda"                         
         , alte = "antigua and barbuda"
         )#end list
   , list( iata = "bes"
         , full = "bonaire, saint eustatius and saba"           
         , alte = "bonaire"
         )#end list
   , list( iata = "bhs"
         , full = "bahamas"                                     
         , alte = "bahamas"
         )#end list
   , list( iata = "blm"
         , full = "saint barthelemy"                            
         , alte = "st barthlemy"
         )#end list
   , list( iata = "blz"
         , full = "belize"                                      
         , alte = "belize"
         )#end list
   , list( iata = "bmu"
         , full = "bermuda"                                     
         , alte = "bermuda"
         )#end list
   , list( iata = "bol"
         , full = "plurinational state of bolivia"              
         , alte = "bolivia"
         )#end list
   , list( iata = "bra"
         , full = "brazil"                                      
         , alte = "brazil"
         )#end list
   , list( iata = "brb"
         , full = "barbados"                                    
         , alte = "barbados"
         )#end list
   , list( iata = "can"
         , full = "canada"                                      
         , alte = "canada"
         )#end list
   , list( iata = "chl"
         , full = "chile"                                       
         , alte = "chile"
         )#end list
   , list( iata = "col"
         , full = "colombia"                                    
         , alte = "colombia"
         )#end list
   , list( iata = "cri"
         , full = "costa rica"                                  
         , alte = "costa rica"
         )#end list
   , list( iata = "cub"
         , full = "cuba"                                        
         , alte = "cuba"
         )#end list
   , list( iata = "cuw"
         , full = "curacao"                                     
         , alte = "curacao"
         )#end list
   , list( iata = "cym"
         , full = "cayman islands"                              
         , alte = "cayman"
         )#end list
   , list( iata = "dma"
         , full = "dominica"                                    
         , alte = "dominica"
         )#end list
   , list( iata = "dom"
         , full = "dominican republic"                          
         , alte = "dominican rep"
         )#end list
   , list( iata = "ecu"
         , full = "ecuador"                                     
         , alte = "ecuador"
         )#end list
   , list( iata = "flk"
         , full = "falkland islands"                            
         , alte = "malvinas"
         )#end list
   , list( iata = "glp"
         , full = "guadeloupe"                                  
         , alte = "guadeloupe"
         )#end list
   , list( iata = "grd"
         , full = "grenada"                                     
         , alte = "grenada"
         )#end list
   , list( iata = "grl"
         , full = "greenland"                                   
         , alte = "greenland"
         )#end list
   , list( iata = "gtm"
         , full = "guatemala"                                   
         , alte = "guatemala"
         )#end list
   , list( iata = "guf"
         , full = "french guiana"                               
         , alte = "french guiana"
         )#end list
   , list( iata = "guy"
         , full = "guyana"                                      
         , alte = "guyana"
         )#end list
   , list( iata = "hnd"
         , full = "honduras"                                    
         , alte = "honduras"
         )#end list
   , list( iata = "hti"
         , full = "haiti"                                       
         , alte = "haiti"
         )#end list
   , list( iata = "jam"
         , full = "jamaica"                                     
         , alte = "jamaica"
         )#end list
   , list( iata = "kna"
         , full = "saint kitts and nevis"                       
         , alte = "saint kitts and nevis"
         )#end list
   , list( iata = "lca"
         , full = "saint lucia"                                 
         , alte = "saint lucia"
         )#end list
   , list( iata = "maf"
         , full = "saint martin"                                
         , alte = "saint martin"
         )#end list
   , list( iata = "mex"
         , full = "mexico"                                      
         , alte = "mexico"
         )#end list
   , list( iata = "msr"
         , full = "montserrat"                                  
         , alte = "montserrat"
         )#end list
   , list( iata = "mtq"
         , full = "martinique"                                  
         , alte = "martinique"
         )#end list
   , list( iata = "nic"
         , full = "nicaragua"                                   
         , alte = "nicaragua"
         )#end list
   , list( iata = "pan"
         , full = "panama"                                      
         , alte = "panama"
         )#end list
   , list( iata = "per"
         , full = "peru"                                        
         , alte = "peru"
         )#end list
   , list( iata = "pri"
         , full = "puerto rico"                                 
         , alte = "puerto rico"
         )#end list
   , list( iata = "pry"
         , full = "paraguay"                                    
         , alte = "paraguay"
         )#end list
   , list( iata = "sgs"
         , full = "south georgia and the south sandwich islands"
         , alte = "south georgia"
         )#end list
   , list( iata = "slv"
         , full = "el salvador"                                 
         , alte = "el salvador"
         )#end list
   , list( iata = "spm"
         , full = "saint pierre and miquelon"                   
         , alte = "saint pierre and miquelon"
         )#end list
   , list( iata = "sur"
         , full = "suriname"                                    
         , alte = "suriname"
         )#end list
   , list( iata = "sxm"
         , full = "sint maarten"                                
         , alte = "sint maarten"
         )#end list
   , list( iata = "tca"
         , full = "turks and caicos islands"                    
         , alte = "turks and caicos"
         )#end list
   , list( iata = "tto"
         , full = "trinidad and tobago"                         
         , alte = "trinidad and tobago"
         )#end list
   , list( iata = "ury"
         , full = "uruguay"                                     
         , alte = "uruguay"
         )#end list
   , list( iata = "usa"
         , full = "united states"                               
         , alte = "usa"
         )#end list
   , list( iata = "vct"
         , full = "saint vincent and the grenadines"            
         , alte = "saint vincent and grenadines"
         )#end list
   , list( iata = "ven"
         , full = "bolivarian republic of venezuela"            
         , alte = "venezuela"
         )#end list
#   , list( iata = "vgb"
#         , full = "british virgin islands"                      
#         , alte = "british virgin islands"
#         )#end list
   , list( iata = "vir"
         , full = "u.s. virgin islands"                         
         , alte = "u.s. virgin islands"
         )#end list
   )#end list
#------------------------------------------------------------------------------------------#






#------------------------------------------------------------------------------------------#
#     List of all national subdivisions.                                                   #
#------------------------------------------------------------------------------------------#
state.tmp <<- list(
     list( iata = "ac", full = "acre"                    , country = "bra", std = TRUE  )
   , list( iata = "al", full = "alagoas"                 , country = "bra", std = TRUE  )
   , list( iata = "am", full = "amazonas"                , country = "bra", std = TRUE  )
   , list( iata = "ap", full = "amapa"                   , country = "bra", std = TRUE  )
   , list( iata = "ar", full = "atol das rocas"          , country = "bra", std = TRUE  )
   , list( iata = "ba", full = "bahia"                   , country = "bra", std = TRUE  )
   , list( iata = "ce", full = "ceara"                   , country = "bra", std = TRUE  )
   , list( iata = "df", full = "distrito federal"        , country = "bra", std = TRUE  )
   , list( iata = "es", full = "espirito santo"          , country = "bra", std = TRUE  )
   , list( iata = "fn", full = "fernando de noronha"     , country = "bra", std = TRUE  )
   , list( iata = "go", full = "goias"                   , country = "bra", std = TRUE  )
   , list( iata = "it", full = "trindade"                , country = "bra", std = TRUE  )
   , list( iata = "ma", full = "maranhao"                , country = "bra", std = TRUE  )
   , list( iata = "mg", full = "minas gerais"            , country = "bra", std = TRUE  )
   , list( iata = "ms", full = "mato grosso do sul"      , country = "bra", std = TRUE  )
   , list( iata = "mt", full = "mato grosso"             , country = "bra", std = TRUE  )
   , list( iata = "mv", full = "martim vaz"              , country = "bra", std = TRUE  )
   , list( iata = "my", full = "maranhao cocais"         , country = "bra", std = FALSE )
   , list( iata = "mz", full = "maranhao amazonia"       , country = "bra", std = FALSE )
   , list( iata = "pa", full = "para"                    , country = "bra", std = TRUE  )
   , list( iata = "pb", full = "paraiba"                 , country = "bra", std = TRUE  )
   , list( iata = "pe", full = "pernambuco"              , country = "bra", std = TRUE  )
   , list( iata = "pi", full = "piaui"                   , country = "bra", std = TRUE  )
   , list( iata = "pn", full = "sao pedro e sao paulo"   , country = "bra", std = TRUE  )
   , list( iata = "pr", full = "parana"                  , country = "bra", std = TRUE  )
   , list( iata = "rj", full = "rio de janeiro"          , country = "bra", std = TRUE  )
   , list( iata = "rn", full = "rio grande do norte"     , country = "bra", std = TRUE  )
   , list( iata = "ro", full = "rondonia"                , country = "bra", std = TRUE  )
   , list( iata = "rr", full = "roraima"                 , country = "bra", std = TRUE  )
   , list( iata = "rs", full = "rio grande do sul"       , country = "bra", std = TRUE  )
   , list( iata = "sc", full = "santa catarina"          , country = "bra", std = TRUE  )
   , list( iata = "se", full = "sergipe"                 , country = "bra", std = TRUE  )
   , list( iata = "sp", full = "sao paulo"               , country = "bra", std = TRUE  )
   , list( iata = "to", full = "tocantins"               , country = "bra", std = TRUE  )
   , list( iata = "sk", full = "saint kitts"             , country = "kna", std = TRUE  )
   , list( iata = "ne", full = "nevis"                   , country = "kna", std = TRUE  )
   , list( iata = "an", full = "antigua"                 , country = "atg", std = TRUE  )
   , list( iata = "ba", full = "barbuda"                 , country = "atg", std = TRUE  )
   , list( iata = "to", full = "tobago"                  , country = "tto", std = TRUE  )
   , list( iata = "tr", full = "trinidad"                , country = "tto", std = TRUE  )
   , list( iata = "bo", full = "bonaire"                 , country = "bes", std = TRUE  )
   , list( iata = "se", full = "sint eustatius"          , country = "bes", std = TRUE  )
   , list( iata = "cb", full = "cochabamba"              , country = "bol", std = FALSE )
   , list( iata = "cq", full = "chuquisaca"              , country = "bol", std = FALSE )
   , list( iata = "eb", full = "el beni"                 , country = "bol", std = FALSE )
   , list( iata = "lp", full = "la paz"                  , country = "bol", std = FALSE )
   , list( iata = "or", full = "oruro"                   , country = "bol", std = FALSE )
   , list( iata = "pa", full = "pando"                   , country = "bol", std = FALSE )
   , list( iata = "po", full = "potosi"                  , country = "bol", std = FALSE )
   , list( iata = "sc", full = "santa cruz"              , country = "bol", std = FALSE )
   , list( iata = "tr", full = "tarija"                  , country = "bol", std = FALSE )
   , list( iata = "am", full = "amazonas"                , country = "per", std = FALSE )
   , list( iata = "an", full = "ancash"                  , country = "per", std = FALSE )
   , list( iata = "ap", full = "apurimac"                , country = "per", std = FALSE )
   , list( iata = "ar", full = "arequipa"                , country = "per", std = FALSE )
   , list( iata = "ay", full = "ayacucho"                , country = "per", std = FALSE )
   , list( iata = "cj", full = "cajamarca"               , country = "per", std = FALSE )
   , list( iata = "cl", full = "callao"                  , country = "per", std = FALSE )
   , list( iata = "cs", full = "cusco"                   , country = "per", std = FALSE )
   , list( iata = "hv", full = "huancavelica"            , country = "per", std = FALSE )
   , list( iata = "hc", full = "huanuco"                 , country = "per", std = FALSE )
   , list( iata = "ic", full = "ica"                     , country = "per", std = FALSE )
   , list( iata = "ju", full = "junin"                   , country = "per", std = FALSE )
   , list( iata = "ll", full = "la libertad"             , country = "per", std = FALSE )
   , list( iata = "lb", full = "lambayeque"              , country = "per", std = FALSE )
   , list( iata = "lr", full = "lima"                    , country = "per", std = FALSE )
   , list( iata = "lo", full = "loreto"                  , country = "per", std = FALSE )
   , list( iata = "md", full = "madre de dios"           , country = "per", std = FALSE )
   , list( iata = "mq", full = "moquegua"                , country = "per", std = FALSE )
   , list( iata = "pa", full = "pasco"                   , country = "per", std = FALSE )
   , list( iata = "pi", full = "piura"                   , country = "per", std = FALSE )
   , list( iata = "pu", full = "puno"                    , country = "per", std = FALSE )
   , list( iata = "sm", full = "san martin"              , country = "per", std = FALSE )
   , list( iata = "ta", full = "tacna"                   , country = "per", std = FALSE )
   , list( iata = "tu", full = "tumbes"                  , country = "per", std = FALSE )
   , list( iata = "uc", full = "ucayali"                 , country = "per", std = FALSE )

   )#end list
#------------------------------------------------------------------------------------------#

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


#------------------------------------------------------------------------------------------#
#    Turn this into a neat data frame.                                                     #
#------------------------------------------------------------------------------------------#
   #----- Make the country table global. --------------------------------------------------#
   ncountries <<- length(country.tmp)
   country.list = list()
   for (ct in sequence(ncountries)){
      for (n in union(names(country.list),names(country.tmp[[ct]]))){
         country.list[[n]] = c(country.list[[n]],country.tmp[[ct]][[n]])
      }#end for
      #------------------------------------------------------------------------------------#
   }#end for
   #---------------------------------------------------------------------------------------#
   country.list <<- data.frame(country.list,stringsAsFactors=FALSE)
   #---------------------------------------------------------------------------------------#

   #----- Make the state table global. ----------------------------------------------------#
   nstates <<- length(state.tmp)
   state.list = list()
   for (st in sequence(nstates)){
      for (n in union(names(state.list),names(state.tmp[[st]]))){
         state.list[[n]] = c(state.list[[n]],state.tmp[[st]][[n]])
      }#end for
      #------------------------------------------------------------------------------------#
   }#end for
   #---------------------------------------------------------------------------------------#
   state.list <<- data.frame(state.list,stringsAsFactors=FALSE)
   #---------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
manfredo89/ED2io documentation built on May 21, 2019, 11:24 a.m.