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