Learn R Programming

BeeBDC (version 1.3.1)

countryHarmoniseR: Match and harmonise country names

Description

A small function that is useful for harmonising country names so that they mathc between datasets. This relies on the country names matching one of the exceptions pre-coded in and is so far used internally.

Usage

countryHarmoniseR(
  data = NULL,
  countryColumn = NULL,
  shorterNames = TRUE,
  continentAnalysis = FALSE
)

Value

Returns the original data frame or tibble but with harmonised country names

Arguments

data

A data frame or tibble.

countryColumn

Character. The column that contains country names to be harmonised.

shorterNames

Logical. If TRUE, some very long country names will be shortened. This can be helpful for writing country names in plots where long names are annoying.

continentAnalysis

Logical. Set to TRUE in order to match small entities to continents; limited use for the moment.

Examples

Run this code
# load in the test dataset
system.file("extdata", "testTaxonomy.rda", package="BeeBDC") |> load()
harmonisedCountries <- countryHarmoniseR(
  data = testTaxonomy,
  countryColumn = "country_suggested"
)

Run the code above in your browser using DataLab