Skip to contents

This function returns the mode of vectors. That is to say, for any given vector of values, it returns the value that appears most frequently. The function works with strings, numerical and mixed inputs. NA values are treated as distinct values.

Usage

random_countries(n, replace = FALSE, nomenclature = "name_en", seed = NULL)

Arguments

n

Number of desired (pseudo)random country names.

replace

Logical value indicating whether sampling should be with replacement.

nomenclature

Nomenclature from which the list of countries should be taken. Not all countries are present in all nomenclature, for example Taiwan is not recognised by the UN, so it will not be returned with "WTO_en". The function accept any of the nomenclatures of country_name. For a list of accepted values, refer to this page. The default is name_en, which is the English list of names in the ISO standard 3166.

seed

Single numerical value to be used as seed.

Value

A vector of n (pseudo)random country names.

Examples

random_countries(10)
#>  [1] "Timor-Leste"               "Gabon"                    
#>  [3] "Turks and Caicos Islands"  "Lithuania"                
#>  [5] "Mauritania"                "Jersey"                   
#>  [7] "Korea, Republic of"        "Taiwan, Province of China"
#>  [9] "South Africa"              "Bouvet Island"            
random_countries(n = 500, replace = TRUE)
#>   [1] "Cocos (Keeling) Islands"                             
#>   [2] "Nigeria"                                             
#>   [3] "Guam"                                                
#>   [4] "Saint Barthélemy"                                    
#>   [5] "Benin"                                               
#>   [6] "Hungary"                                             
#>   [7] "Samoa"                                               
#>   [8] "Northern Mariana Islands"                            
#>   [9] "French Guiana"                                       
#>  [10] "Senegal"                                             
#>  [11] "Northern Mariana Islands"                            
#>  [12] "Philippines"                                         
#>  [13] "Azerbaijan"                                          
#>  [14] "Suriname"                                            
#>  [15] "Congo, Democratic Republic of the"                   
#>  [16] "British Indian Ocean Territory"                      
#>  [17] "Viet Nam"                                            
#>  [18] "Namibia"                                             
#>  [19] "Algeria"                                             
#>  [20] "Bolivia (Plurinational State of)"                    
#>  [21] "Morocco"                                             
#>  [22] "Estonia"                                             
#>  [23] "Belgium"                                             
#>  [24] "Pakistan"                                            
#>  [25] "Mauritius"                                           
#>  [26] "New Caledonia"                                       
#>  [27] "Paraguay"                                            
#>  [28] "Greenland"                                           
#>  [29] "Ghana"                                               
#>  [30] "Cambodia"                                            
#>  [31] "Serbia"                                              
#>  [32] "Paraguay"                                            
#>  [33] "Lebanon"                                             
#>  [34] "Sierra Leone"                                        
#>  [35] "Australia"                                           
#>  [36] "New Zealand"                                         
#>  [37] "Gibraltar"                                           
#>  [38] "Cocos (Keeling) Islands"                             
#>  [39] "Mauritius"                                           
#>  [40] "Suriname"                                            
#>  [41] "Mayotte"                                             
#>  [42] "Argentina"                                           
#>  [43] "Cook Islands"                                        
#>  [44] "Lao People's Democratic Republic"                    
#>  [45] "Niger"                                               
#>  [46] "Georgia"                                             
#>  [47] "Sao Tome and Principe"                               
#>  [48] "Cuba"                                                
#>  [49] "Syrian Arab Republic"                                
#>  [50] "Malawi"                                              
#>  [51] "Czechia"                                             
#>  [52] "Micronesia (Federated States of)"                    
#>  [53] "Gibraltar"                                           
#>  [54] "Israel"                                              
#>  [55] "Grenada"                                             
#>  [56] "Uruguay"                                             
#>  [57] "South Georgia and the South Sandwich Islands"        
#>  [58] "Panama"                                              
#>  [59] "South Africa"                                        
#>  [60] "Jamaica"                                             
#>  [61] "Dominican Republic"                                  
#>  [62] "Cayman Islands"                                      
#>  [63] "Senegal"                                             
#>  [64] "Heard Island and McDonald Islands"                   
#>  [65] "Bonaire, Sint Eustatius and Saba"                    
#>  [66] "Ecuador"                                             
#>  [67] "Comoros"                                             
#>  [68] "Bonaire, Sint Eustatius and Saba"                    
#>  [69] "Tuvalu"                                              
#>  [70] "Saint Helena, Ascension and Tristan da Cunha"        
#>  [71] "Cook Islands"                                        
#>  [72] "Solomon Islands"                                     
#>  [73] "Korea (Democratic People's Republic of)"             
#>  [74] "Bahrain"                                             
#>  [75] "Barbados"                                            
#>  [76] "Morocco"                                             
#>  [77] "Japan"                                               
#>  [78] "Trinidad and Tobago"                                 
#>  [79] "Tajikistan"                                          
#>  [80] "United States of America"                            
#>  [81] "North Macedonia"                                     
#>  [82] "Ethiopia"                                            
#>  [83] "Gabon"                                               
#>  [84] "Marshall Islands"                                    
#>  [85] "Latvia"                                              
#>  [86] "Monaco"                                              
#>  [87] "Togo"                                                
#>  [88] "Central African Republic"                            
#>  [89] "Bulgaria"                                            
#>  [90] "Isle of Man"                                         
#>  [91] "Algeria"                                             
#>  [92] "Saint Pierre and Miquelon"                           
#>  [93] "Iceland"                                             
#>  [94] "United Arab Emirates"                                
#>  [95] "Panama"                                              
#>  [96] "Peru"                                                
#>  [97] "Saint Pierre and Miquelon"                           
#>  [98] "Ecuador"                                             
#>  [99] "Faroe Islands"                                       
#> [100] "Virgin Islands (British)"                            
#> [101] "Mauritania"                                          
#> [102] "Côte d'Ivoire"                                       
#> [103] "Guinea"                                              
#> [104] "Indonesia"                                           
#> [105] "Latvia"                                              
#> [106] "Panama"                                              
#> [107] "Pakistan"                                            
#> [108] "United States of America"                            
#> [109] "Holy See"                                            
#> [110] "Togo"                                                
#> [111] "Congo, Democratic Republic of the"                   
#> [112] "French Southern Territories"                         
#> [113] "Guatemala"                                           
#> [114] "Dominica"                                            
#> [115] "Thailand"                                            
#> [116] "South Sudan"                                         
#> [117] "Maldives"                                            
#> [118] "Uganda"                                              
#> [119] "Wallis and Futuna"                                   
#> [120] "Belize"                                              
#> [121] "Spain"                                               
#> [122] "Argentina"                                           
#> [123] "Kenya"                                               
#> [124] "Wallis and Futuna"                                   
#> [125] "Indonesia"                                           
#> [126] "Portugal"                                            
#> [127] "Christmas Island"                                    
#> [128] "Sudan"                                               
#> [129] "Saint Lucia"                                         
#> [130] "Trinidad and Tobago"                                 
#> [131] "Kyrgyzstan"                                          
#> [132] "Armenia"                                             
#> [133] "Virgin Islands (U.S.)"                               
#> [134] "Lesotho"                                             
#> [135] "Liberia"                                             
#> [136] "Gibraltar"                                           
#> [137] "British Indian Ocean Territory"                      
#> [138] "Samoa"                                               
#> [139] "Cameroon"                                            
#> [140] "Mali"                                                
#> [141] "Syrian Arab Republic"                                
#> [142] "San Marino"                                          
#> [143] "Cyprus"                                              
#> [144] "Austria"                                             
#> [145] "Curaçao"                                             
#> [146] "Switzerland"                                         
#> [147] "Botswana"                                            
#> [148] "Netherlands"                                         
#> [149] "Kuwait"                                              
#> [150] "Antigua and Barbuda"                                 
#> [151] "Kyrgyzstan"                                          
#> [152] "Ecuador"                                             
#> [153] "North Macedonia"                                     
#> [154] "Bangladesh"                                          
#> [155] "Saint Kitts and Nevis"                               
#> [156] "Rwanda"                                              
#> [157] "Russian Federation"                                  
#> [158] "Bahrain"                                             
#> [159] "Cabo Verde"                                          
#> [160] "Ghana"                                               
#> [161] "Holy See"                                            
#> [162] "China"                                               
#> [163] "Kuwait"                                              
#> [164] "Lebanon"                                             
#> [165] "Moldova, Republic of"                                
#> [166] "Grenada"                                             
#> [167] "Bonaire, Sint Eustatius and Saba"                    
#> [168] "Christmas Island"                                    
#> [169] "Malta"                                               
#> [170] "Comoros"                                             
#> [171] "Congo, Democratic Republic of the"                   
#> [172] "Tajikistan"                                          
#> [173] "Ireland"                                             
#> [174] "French Southern Territories"                         
#> [175] "Nicaragua"                                           
#> [176] "Andorra"                                             
#> [177] "Zimbabwe"                                            
#> [178] "Guam"                                                
#> [179] "Guernsey"                                            
#> [180] "Ghana"                                               
#> [181] "Christmas Island"                                    
#> [182] "Nicaragua"                                           
#> [183] "Belarus"                                             
#> [184] "Guinea"                                              
#> [185] "Mexico"                                              
#> [186] "Saint Lucia"                                         
#> [187] "Albania"                                             
#> [188] "Latvia"                                              
#> [189] "Myanmar"                                             
#> [190] "Congo, Democratic Republic of the"                   
#> [191] "Niue"                                                
#> [192] "Israel"                                              
#> [193] "Montserrat"                                          
#> [194] "Ecuador"                                             
#> [195] "South Georgia and the South Sandwich Islands"        
#> [196] "Bosnia and Herzegovina"                              
#> [197] "Lithuania"                                           
#> [198] "Maldives"                                            
#> [199] "Argentina"                                           
#> [200] "Holy See"                                            
#> [201] "Viet Nam"                                            
#> [202] "Lebanon"                                             
#> [203] "Korea (Democratic People's Republic of)"             
#> [204] "Zimbabwe"                                            
#> [205] "Ireland"                                             
#> [206] "Côte d'Ivoire"                                       
#> [207] "Comoros"                                             
#> [208] "Sudan"                                               
#> [209] "France"                                              
#> [210] "Estonia"                                             
#> [211] "French Polynesia"                                    
#> [212] "Malta"                                               
#> [213] "Sudan"                                               
#> [214] "Belarus"                                             
#> [215] "Finland"                                             
#> [216] "Turkmenistan"                                        
#> [217] "Sudan"                                               
#> [218] "Western Sahara"                                      
#> [219] "Czechia"                                             
#> [220] "Réunion"                                             
#> [221] "Côte d'Ivoire"                                       
#> [222] "Ethiopia"                                            
#> [223] "Nigeria"                                             
#> [224] "Kazakhstan"                                          
#> [225] "Netherlands"                                         
#> [226] "Cocos (Keeling) Islands"                             
#> [227] "Lebanon"                                             
#> [228] "Honduras"                                            
#> [229] "Monaco"                                              
#> [230] "Palestine, State of"                                 
#> [231] "Curaçao"                                             
#> [232] "New Caledonia"                                       
#> [233] "Jordan"                                              
#> [234] "Maldives"                                            
#> [235] "Venezuela (Bolivarian Republic of)"                  
#> [236] "Bosnia and Herzegovina"                              
#> [237] "Botswana"                                            
#> [238] "Micronesia (Federated States of)"                    
#> [239] "Myanmar"                                             
#> [240] "Senegal"                                             
#> [241] "British Indian Ocean Territory"                      
#> [242] "Korea (Democratic People's Republic of)"             
#> [243] "Taiwan, Province of China"                           
#> [244] "Nauru"                                               
#> [245] "Nigeria"                                             
#> [246] "Yemen"                                               
#> [247] "Gabon"                                               
#> [248] "Zimbabwe"                                            
#> [249] "Argentina"                                           
#> [250] "Guadeloupe"                                          
#> [251] "Anguilla"                                            
#> [252] "Nicaragua"                                           
#> [253] "Solomon Islands"                                     
#> [254] "Iraq"                                                
#> [255] "Burkina Faso"                                        
#> [256] "Ethiopia"                                            
#> [257] "Poland"                                              
#> [258] "Honduras"                                            
#> [259] "Andorra"                                             
#> [260] "Gibraltar"                                           
#> [261] "Pitcairn"                                            
#> [262] "Tuvalu"                                              
#> [263] "Tajikistan"                                          
#> [264] "Liechtenstein"                                       
#> [265] "Singapore"                                           
#> [266] "Malaysia"                                            
#> [267] "Canada"                                              
#> [268] "China"                                               
#> [269] "Jordan"                                              
#> [270] "Mali"                                                
#> [271] "Cocos (Keeling) Islands"                             
#> [272] "Réunion"                                             
#> [273] "United States of America"                            
#> [274] "Iran (Islamic Republic of)"                          
#> [275] "Portugal"                                            
#> [276] "Mongolia"                                            
#> [277] "Bangladesh"                                          
#> [278] "Cambodia"                                            
#> [279] "Iran (Islamic Republic of)"                          
#> [280] "Curaçao"                                             
#> [281] "Algeria"                                             
#> [282] "Samoa"                                               
#> [283] "New Zealand"                                         
#> [284] "Solomon Islands"                                     
#> [285] "Virgin Islands (U.S.)"                               
#> [286] "Barbados"                                            
#> [287] "Malaysia"                                            
#> [288] "Curaçao"                                             
#> [289] "New Caledonia"                                       
#> [290] "Holy See"                                            
#> [291] "Jersey"                                              
#> [292] "Kyrgyzstan"                                          
#> [293] "Turks and Caicos Islands"                            
#> [294] "Norfolk Island"                                      
#> [295] "Ireland"                                             
#> [296] "Senegal"                                             
#> [297] "Gabon"                                               
#> [298] "Uzbekistan"                                          
#> [299] "Zimbabwe"                                            
#> [300] "Gambia"                                              
#> [301] "Fiji"                                                
#> [302] "Indonesia"                                           
#> [303] "Åland Islands"                                       
#> [304] "China"                                               
#> [305] "Cyprus"                                              
#> [306] "Luxembourg"                                          
#> [307] "Armenia"                                             
#> [308] "Portugal"                                            
#> [309] "Comoros"                                             
#> [310] "Cocos (Keeling) Islands"                             
#> [311] "Anguilla"                                            
#> [312] "Holy See"                                            
#> [313] "Serbia"                                              
#> [314] "Anguilla"                                            
#> [315] "Palau"                                               
#> [316] "Tajikistan"                                          
#> [317] "Italy"                                               
#> [318] "Cocos (Keeling) Islands"                             
#> [319] "Romania"                                             
#> [320] "Malaysia"                                            
#> [321] "Croatia"                                             
#> [322] "Curaçao"                                             
#> [323] "Ecuador"                                             
#> [324] "Palestine, State of"                                 
#> [325] "Nigeria"                                             
#> [326] "Liberia"                                             
#> [327] "South Sudan"                                         
#> [328] "Sint Maarten (Dutch part)"                           
#> [329] "Christmas Island"                                    
#> [330] "Iceland"                                             
#> [331] "French Southern Territories"                         
#> [332] "Togo"                                                
#> [333] "Guadeloupe"                                          
#> [334] "Kyrgyzstan"                                          
#> [335] "French Polynesia"                                    
#> [336] "Solomon Islands"                                     
#> [337] "Iran (Islamic Republic of)"                          
#> [338] "Macao"                                               
#> [339] "Spain"                                               
#> [340] "Svalbard and Jan Mayen"                              
#> [341] "Philippines"                                         
#> [342] "Yemen"                                               
#> [343] "Liechtenstein"                                       
#> [344] "Belize"                                              
#> [345] "Western Sahara"                                      
#> [346] "French Polynesia"                                    
#> [347] "Cayman Islands"                                      
#> [348] "Greenland"                                           
#> [349] "Armenia"                                             
#> [350] "Falkland Islands (Malvinas)"                         
#> [351] "Namibia"                                             
#> [352] "Tajikistan"                                          
#> [353] "Sudan"                                               
#> [354] "Bonaire, Sint Eustatius and Saba"                    
#> [355] "Barbados"                                            
#> [356] "Heard Island and McDonald Islands"                   
#> [357] "Bangladesh"                                          
#> [358] "Sri Lanka"                                           
#> [359] "Romania"                                             
#> [360] "Virgin Islands (U.S.)"                               
#> [361] "Mayotte"                                             
#> [362] "Turkmenistan"                                        
#> [363] "Netherlands"                                         
#> [364] "Tunisia"                                             
#> [365] "Tuvalu"                                              
#> [366] "Iran (Islamic Republic of)"                          
#> [367] "Mexico"                                              
#> [368] "Saudi Arabia"                                        
#> [369] "Montenegro"                                          
#> [370] "Uzbekistan"                                          
#> [371] "Montenegro"                                          
#> [372] "Gibraltar"                                           
#> [373] "Samoa"                                               
#> [374] "Tunisia"                                             
#> [375] "Seychelles"                                          
#> [376] "Turks and Caicos Islands"                            
#> [377] "Chile"                                               
#> [378] "Panama"                                              
#> [379] "Brunei Darussalam"                                   
#> [380] "Luxembourg"                                          
#> [381] "Nepal"                                               
#> [382] "Thailand"                                            
#> [383] "French Polynesia"                                    
#> [384] "Mozambique"                                          
#> [385] "Martinique"                                          
#> [386] "Western Sahara"                                      
#> [387] "Indonesia"                                           
#> [388] "Cambodia"                                            
#> [389] "United Kingdom of Great Britain and Northern Ireland"
#> [390] "Bermuda"                                             
#> [391] "Armenia"                                             
#> [392] "Guyana"                                              
#> [393] "Nigeria"                                             
#> [394] "Egypt"                                               
#> [395] "Pakistan"                                            
#> [396] "Saint Barthélemy"                                    
#> [397] "Saint Martin (French part)"                          
#> [398] "Croatia"                                             
#> [399] "Panama"                                              
#> [400] "Gabon"                                               
#> [401] "Tanzania, United Republic of"                        
#> [402] "Senegal"                                             
#> [403] "Niger"                                               
#> [404] "Poland"                                              
#> [405] "Portugal"                                            
#> [406] "Tajikistan"                                          
#> [407] "Australia"                                           
#> [408] "China"                                               
#> [409] "French Guiana"                                       
#> [410] "Dominican Republic"                                  
#> [411] "Philippines"                                         
#> [412] "Sweden"                                              
#> [413] "Saint Lucia"                                         
#> [414] "Mozambique"                                          
#> [415] "Mauritius"                                           
#> [416] "Burundi"                                             
#> [417] "Western Sahara"                                      
#> [418] "Botswana"                                            
#> [419] "Norfolk Island"                                      
#> [420] "American Samoa"                                      
#> [421] "Cayman Islands"                                      
#> [422] "Holy See"                                            
#> [423] "Malaysia"                                            
#> [424] "Honduras"                                            
#> [425] "San Marino"                                          
#> [426] "Puerto Rico"                                         
#> [427] "Eritrea"                                             
#> [428] "Andorra"                                             
#> [429] "Korea (Democratic People's Republic of)"             
#> [430] "French Southern Territories"                         
#> [431] "Malawi"                                              
#> [432] "Congo"                                               
#> [433] "Tuvalu"                                              
#> [434] "Kuwait"                                              
#> [435] "Trinidad and Tobago"                                 
#> [436] "Iran (Islamic Republic of)"                          
#> [437] "Micronesia (Federated States of)"                    
#> [438] "Samoa"                                               
#> [439] "Andorra"                                             
#> [440] "Korea, Republic of"                                  
#> [441] "Iraq"                                                
#> [442] "Belize"                                              
#> [443] "United States of America"                            
#> [444] "Paraguay"                                            
#> [445] "Qatar"                                               
#> [446] "Finland"                                             
#> [447] "Japan"                                               
#> [448] "Portugal"                                            
#> [449] "Saint Helena, Ascension and Tristan da Cunha"        
#> [450] "Guyana"                                              
#> [451] "Burkina Faso"                                        
#> [452] "Guadeloupe"                                          
#> [453] "Vanuatu"                                             
#> [454] "Denmark"                                             
#> [455] "Ukraine"                                             
#> [456] "Bouvet Island"                                       
#> [457] "Tanzania, United Republic of"                        
#> [458] "Guam"                                                
#> [459] "Tanzania, United Republic of"                        
#> [460] "Somalia"                                             
#> [461] "Saint Kitts and Nevis"                               
#> [462] "Antarctica"                                          
#> [463] "Australia"                                           
#> [464] "Macao"                                               
#> [465] "British Indian Ocean Territory"                      
#> [466] "Honduras"                                            
#> [467] "Dominica"                                            
#> [468] "Brazil"                                              
#> [469] "Algeria"                                             
#> [470] "Tuvalu"                                              
#> [471] "Poland"                                              
#> [472] "Tonga"                                               
#> [473] "Cameroon"                                            
#> [474] "India"                                               
#> [475] "Guam"                                                
#> [476] "Turks and Caicos Islands"                            
#> [477] "Pitcairn"                                            
#> [478] "Guatemala"                                           
#> [479] "Saint Helena, Ascension and Tristan da Cunha"        
#> [480] "Ethiopia"                                            
#> [481] "Denmark"                                             
#> [482] "Burundi"                                             
#> [483] "Gambia"                                              
#> [484] "Uruguay"                                             
#> [485] "Bosnia and Herzegovina"                              
#> [486] "Northern Mariana Islands"                            
#> [487] "South Georgia and the South Sandwich Islands"        
#> [488] "Kenya"                                               
#> [489] "Canada"                                              
#> [490] "Czechia"                                             
#> [491] "Saint Lucia"                                         
#> [492] "Turks and Caicos Islands"                            
#> [493] "France"                                              
#> [494] "Palestine, State of"                                 
#> [495] "Senegal"                                             
#> [496] "Turkmenistan"                                        
#> [497] "Andorra"                                             
#> [498] "France"                                              
#> [499] "Norway"                                              
#> [500] "Central African Republic"                            
random_countries(n = 5, nomenclature = "ISO3", seed = 5)
#> [1] "DJI" "IND" "RWA" "ZAF" "SVK"