use_iso_countries: Replace country names with 3-letter ISO abbreviations

View source: R/initialize.R

use_iso_countriesR Documentation

Replace country names with 3-letter ISO abbreviations

Description

The IEA uses full country names, but it is more concise to use the 3-letter ISO abbreviations. This function replaces the full country names with ISO abbreviations where possible.

Usage

use_iso_countries(
  .iea_df,
  override_df = IEATools::override_iso_codes_df,
  country = IEATools::iea_cols$country,
  pfu_code = IEATools::country_concordance_cols$pfu_code,
  iea_name = IEATools::country_concordance_cols$iea_name,
  override_suffix = "...override"
)

Arguments

.iea_df

A data frame containing a country column.

override_df

A data frame containing columns named pfu_code and iea_name. Default is IEATools::overide_iso_codes_df.

country

The name of the country column in .iea_df. Default is IEATools::iea_cols$country.

pfu_code, iea_name

See IEATools::countryconcordance_cols.

override_suffix

A suffix added to override columns. Default is "...override".

Details

Internally, the countrycode package is used for ISO codes where possible. Optionally, an override_df can be specified. override_df should contain columns pfu_code (for 3-letter ISO codes) and iea_name for country names.

If neither the countrycode package nor override_df contain a matching country name, the country column is left untouched.

By default, special cases are considered via the override_df argument. The default value of override_df sets codes for China and Hong Kong, as well as World X bunkers.

Value

.iea_df with 3-letter ISO country abbreviations in the country column.

Examples

sample_iea_data_path() %>% 
  iea_df() %>%
  rename_iea_df_cols() %>% 
  use_iso_countries()

MatthewHeun/IEATools documentation built on Feb. 6, 2024, 3:29 p.m.