ucdp_to_peacesciencer() standardizes state-year or dyad-year keys to the
names expected by peacesciencer and declares the corresponding package
attributes. It does not aggregate event data automatically; use
ucdp_aggregate() first when observations are not already unique at the
requested unit.
Arguments
- data
A state-year or dyad-year data frame.
- type
"state-year"or"dyad-year".- system
Target state system:
"gw"or"cow".- code, code2
Source code columns.
code2is required for dyad-years.- year
Year column.
- from
Coding system of the supplied codes. Defaults to
system. If it differs, codes are converted withucdp_country_crosswalk().- crosswalk
Optional frozen crosswalk passed to
ucdp_country_crosswalk().- check_unique
Require one row per state-year or dyad-year key?
Value
A data frame with year and gwcode/ccode keys (or numbered
dyadic variants) and peacesciencer attributes.
Examples
x <- data.frame(country_id = c(2, 20), year = 2020, events = c(1, 3))
if (requireNamespace("peacesciencer", quietly = TRUE)) {
ps <- ucdp_to_peacesciencer(x, code = "country_id")
}