Learn R Programming

countries (version 1.2.2)

random_countries: Output random country names

Description

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)

Value

A vector of n (pseudo)random country names.

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.

See Also

list_countries, country_name

Examples

Run this code
random_countries(10)
random_countries(n = 500, replace = TRUE)
random_countries(n = 5, nomenclature = "ISO3", seed = 5)

Run the code above in your browser using DataLab