cow_iso_clean: Clean Up 'countrycode::countrycode()' CoW > ISO3 conversion.

View source: R/cow_iso_clean.R

cow_iso_cleanR Documentation

Clean Up countrycode::countrycode() CoW > ISO3 conversion.

Description

Given a data.frame with ISO3 country codes that were derived from a countrycode::countrycode() cown > iso3c formula, clean up the common errors in coding respective to an additional designation for the year of the observation.

Usage

cow_iso_clean(x, cow.col, iso3.col, year.col)

Arguments

x

A data.frame with CoW, ISO3, and year designations.

cow.col

A character string of the column name with numeric CoW codes.

iso3.col

A character string of the column name with ISO3 character codes.

year.col

A character string of the column name for country-year observation.

Details

countrycode::countrycode() can result in messy ISO3 conversions; especially when historic data is included. This cleans up some common post-WWII historical (and other current bugs present at the time of publishing) ISO3C codes that are useful but no longer part of the current slate of ISO3C. The ISO_3166-1_alpha-3 Wikipedia page was used as reference for this function.

Value

A data.frame.

Examples


vdem<-demcon::get_vdem()

vdem$iso3<-countrycode::countrycode(vdem$COWcode, origin = "cown", destination = "iso3c")

vdem<-demcon::cow_iso_clean(x = vdem, cow.col = "COWcode", iso3.col = "iso3", year.col = "year")

demcon documentation built on March 31, 2023, 10:27 p.m.