prepCountry: Format Country Name

View source: R/prepCountry.R

prepCountryR Documentation

Format Country Name

Description

Simple function to standardize the notation of country name (administrative level 0) by converting country codes to their long names and by removing special characters and some country name prepositions and separators.

Usage

prepCountry(x, to.lower = TRUE, special.char = FALSE, rm.abbrev = TRUE)

Arguments

x

a vector of country names to be standardized

to.lower

logical. Should the output names be return in lower cases? Default to TRUE.

special.char

logical. Should special characters be maintained? Default to FALSE.

rm.abbrev

logical. Should common name abbreviation be replaced? Default to TRUE.

Details

Country information is formatted into a standard notation, i.e. long name format (in English). By default, all letters are lower-cased (argument to.lower) and special characters (argument special.char) and common abbreviations (e.g. 'st.') are removed (argument rm.abbrev). These edits aim at reducing possible variation in country name notation and facilitate further data processing and comparison within the plantR workflow.

All country information with less than four letters are treated as country codes and they are converted to the long format. Currently, only the ISO 3166-1 alpha-2 and alpha-3 codes are considered for conversion to the long country name format.

Value

The input vector x in the standard name notation (see Details)

Author(s)

Renato A. F. de Lima

Examples

# Creating a data frame with locality information
paises <- c("VC", "VCT", "St. Vincent and the Grenadines",
"St. Vincent & Grenadines", "Saint-Martin", "Falkland Is.", NA)

# Formating the locality information
prepCountry(paises)
prepCountry(paises, to.lower = FALSE)
prepCountry(paises, rm.abbrev = FALSE)


LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.