state_panel {states} | R Documentation |
Create state panel data
Description
Create panel data consisting of independent states in the international system.
Usage
state_panel(start, end, by = NULL, partial = "any", useGW = TRUE)
Arguments
start |
Beginning date for data, see |
end |
End date for data, see |
by |
Temporal resolution, "year", "month", or "day". If NULL, inferred
from start and end input format, e.g. |
partial |
Option for how to handle edge cases where a state is independent
for only part of a time period (year, month, etc.). Options include
|
useGW |
Use Gleditsch & Ward statelist or Correlates of War state system membership list. |
Details
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.
Value
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 inferredby
value is "year"), and abase::Date()
vector with the name "date" otherwise.
Examples
# 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)
cowlist <- state_panel("1991-01-01", "2015-01-01", by = "year",
partial = "any", useGW = FALSE)
head(cowlist, 3)
# 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")
265 %in% gwlist$gwcode
# Partials
# Focus on South Sudan--is there a record for 2011, first year of indendence?
data(gwstates)
dplyr::filter(gwstates, gwcode==626)
# No 2011 because SSD was not indpendent on January 1st 2011
x <- state_panel(2011, 2013, partial = "first")
dplyr::filter(x, gwcode==626)
# 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)
# Includes 2011 because partial = "any"
x <- state_panel("2011-01-01", "2013-01-01", by = "year", partial = "any")
dplyr::filter(x, gwcode==626)