Function for creating standardised country names and ID variables based on
capabilities from the countrycode package. The function also
reports if duplicated country IDs have been created and lets the user either
drop these or return only duplicated values for inspection.
Usage
CountryID(
data,
countryVar = "country",
OutCountryID = "iso2c",
standardCountryName = TRUE,
duplicates = "message",
timeVar = NULL,
fromLast = FALSE
)Arguments
- data
a data frame object
- countryVar
character string naming the country.name variable. See
countrycode.- OutCountryID
character string. The type of country ID you would like to include in the output file along with the country name. See
countrycodefor available options.- standardCountryName
logical. Whether or not to standardise the country names variable based on
country.namefromcountrycode.- duplicates
character string specifying how to handle duplicated country or country-time observations (for the latter see
timeVar). Can be set tononeto do nothing,messageto simply report duplicates,dropto report and drop duplicates, andreturnto return a data frame with only duplicated observations (see alsofromLast).- timeVar
character string indicating the name of a time variable. For example, country time series often have separate rows based on a
yearvariable. This is used solely to determine if there are duplicated country-time values.- fromLast
logical indicating if duplication should be considered from the reverse side. Only relevant if
duplicates = 'drop'orduplicates = 'return'.
