Joins region names onto an existing state panel via
countrycode::countrycode(), mapping the panel's cow/gw codes to one
or more of countrycode's regional classifications. The coding system is
detected automatically from the panel.
Arguments
- panel
A data frame produced by
build_states_panel(), containing acoworgwcolumn.- region
Character vector selecting one or more
countrycodedestination classifications to add, from:"region"(default): World Bank 7-region classification."region23": World Bank's finer, 23-region classification."un.region.name": UN macro-region (continent-level)."un.regionsub.name": UN sub-region.
See
countrycode::countrycode()for details on these classifications.
Value
The input panel with one additional column per entry in
region, named after the classification (e.g. region, region23),
holding the corresponding region name for each row (NA where
countrycode() finds no match).
Examples
panel <- build_states_panel(1990, 2000, coding_system = "cow") |>
add_regions()
panel <- build_states_panel(1990, 2000, coding_system = "cow") |>
add_regions(region = c("region", "un.regionsub.name"))
