This R package includes functions for gathering commonly used and regularly maintained political science data sets. It also includes functions for combining components from these data sets into variables that have been suggested in the literature, but are not regularly maintained.
Functions include:
-
DpiGet
: a function to download the Database of Political Institutions data set. It keeps specified variables and creates a standard country ID variable that can be used for merging the data with other data sets. -
PolityGet
: a function to download the Polity IV data set. It keeps specified variables and creates a standard country ID variable that can be used for merging the data with other data sets. -
RRCrisisGet
: download and combine Reinhart and Rogoff's (2010) crisis dummy variables into one data frame. -
WinsetCreator
: Creates the winset (W) and a modified version of the selectorate (S) variable from Bueno de Mesquita et al. (2003) using the most recent data available from Polity IV and the Database of Political Institutions.
Other functions included that might be useful to people working with political science data:
CountryID
: Function for creating standardised country names and ID variables. This builds on countrycode and includes extra capabilities for reporting and dealing with duplicates.
To create winset (W) and selectorate (ModS) data use the following code:
library(psData)
WinData <- WinsetCreator()
head(WinData)
## iso2c country year W ModS
## 1 AF Afghanistan 1975 0.25 0
## 2 AF Afghanistan 1976 0.25 0
## 3 AF Afghanistan 1977 0.25 0
## 15 AF Afghanistan 1989 0.50 0
## 16 AF Afghanistan 1990 0.50 0
## 17 AF Afghanistan 1991 0.50 0
Note that the iso2c variable refers to the ISO two letter country code country ID. This can be changed with the OutCountryID
argument.
To download only the polity2 variable from Polity IV:
PolityData <- PolityGet(vars = "polity2")
head(PolityData)
## iso2c country year polity2
## 1 AF Afghanistan 1800 -6
## 2 AF Afghanistan 1801 -6
## 3 AF Afghanistan 1802 -6
## 4 AF Afghanistan 1803 -6
## 5 AF Afghanistan 1804 -6
## 6 AF Afghanistan 1805 -6
Please feel free to suggest other data set downloading and variable creating functions. To do this just leave a note on the package's Issues page
pdData will be on CRAN soon, but while it is in the development stage you can install it with the devtools package:
devtools::install_github('psData', 'christophergandrud')