Translate country names to Gleditsch & Ward country codes.

icews_to_gwcode(country, date)

Arguments

country

The character country name in ICEWS

date

Event date; some countries like Yugoslavia/Serbia and Montenegro/Serbia change over time.

Examples

# Territories are correctly associated with metropole
df <- dplyr::tibble(
  country = c("United States", "Puerto Rico", "Guam"),
  event_date = rep(as.Date("2018-01-01")),
  stringsAsFactors = FALSE)
df$gwcode <- icews_to_gwcode(df$country, df$event_date)
df
#> # A tibble: 3 × 4
#>   country       event_date stringsAsFactors gwcode
#>   <chr>         <date>     <lgl>             <int>
#> 1 United States 2018-01-01 FALSE                 2
#> 2 Puerto Rico   2018-01-01 FALSE                 2
#> 3 Guam          2018-01-01 FALSE                 2

# Time-varying translation
df <- dplyr::tibble(
  country = c("Serbia", "Serbia"),
  event_date = as.Date(c("2006-06-04", "2006-06-05")),
  stringsAsFactors = FALSE)
df$gwcode <- icews_to_gwcode(df$country, df$event_date)
df
#> # A tibble: 2 × 4
#>   country event_date stringsAsFactors gwcode
#>   <chr>   <date>     <lgl>             <int>
#> 1 Serbia  2006-06-04 FALSE               345
#> 2 Serbia  2006-06-05 FALSE               340