Create panel data consisting of independent states in the international system.
state_panel(start, end, by = NULL, partial = "any", useGW = TRUE)
Beginning date for data, see parse_date()
for format options.
End date for data, see parse_date()
for format options.
Temporal resolution, "year", "month", or "day". If NULL, inferred
from start and end input format, e.g. start = 2006`` implies
by = "year"`.
Option for how to handle edge cases where a state is independent
for only part of a time period (year, month, etc.). Options include
"exact"
, "first"
, "last"
, and "any"
. See details.
Use Gleditsch & Ward statelist or Correlates of War state system membership list.
A base::data.frame()
with 2 columns for the country code and date
information. The column names and types differ slightly based on the
"useGW" and "by" arguments.
The first column will be "gwcode" if useGW = TRUE
(the default), and
"cowcode" otherwise.
The second column is an integer vector with name "year" for country-year
data (if by
or the inferred by
value is "year"), and a base::Date()
vector with the name "date" otherwise.
The partial option determines how to handle instances where a country gains or loses independence during a time period specified in the by option:
"exact": the exact date in start is used for filtering
"any": a state-period is included if the state was independent at any point in that period.
"first": same as "exact" with the first date in a time period, e.g. "2006-01-01".
"last": last date in a period. For "yearly" data, this is the same as "exact" with a start date like "YYYY-12-21", but for calendar months the last date varies, hence the need for this option.
# Basic usage with full option set specified:
gwlist <- state_panel("1991-01-01", "2015-01-01", by = "year",
partial = "any", useGW = TRUE)
head(gwlist, 3)
#> gwcode year
#> 1 2 1991
#> 2 2 1992
#> 3 2 1993
cowlist <- state_panel("1991-01-01", "2015-01-01", by = "year",
partial = "any", useGW = FALSE)
head(cowlist, 3)
#> cowcode year
#> 1 2 1991
#> 2 2 1992
#> 3 2 1993
# For yearly data, a proper date is not needed, and by = "year" and
# partial = "any" are inferred.
gwlist <- state_panel(1990, 1995)
sfind(265, list = "GW")
#> list ccode code3c country_name start end
#> 46 GW 265 GDR German Democratic Republic 1949-10-05 1990-10-02
#> microstate
#> 46 FALSE
265 %in% gwlist$gwcode
#> [1] TRUE
# Partials
# Focus on South Sudan--is there a record for 2011, first year of indendence?
data(gwstates)
dplyr::filter(gwstates, gwcode==626)
#> gwcode gwc country_name start end microstate
#> 1 626 SSD South Sudan 2011-07-09 9999-12-31 FALSE
# No 2011 because SSD was not indpendent on January 1st 2011
x <- state_panel(2011, 2013, partial = "first")
dplyr::filter(x, gwcode==626)
#> gwcode year
#> 1 626 2012
#> 2 626 2013
# Includes 2011 because 12-31 date is used for filtering
x <- state_panel("2011-12-31", "2013-12-31", by = "year", partial = "exact")
dplyr::filter(x, gwcode==626)
#> gwcode year
#> 1 626 2011
#> 2 626 2012
#> 3 626 2013
# Includes 2011 because partial = "any"
x <- state_panel("2011-01-01", "2013-01-01", by = "year", partial = "any")
dplyr::filter(x, gwcode==626)
#> gwcode year
#> 1 626 2011
#> 2 626 2012
#> 3 626 2013