MyNixOS website logo
Description

Download Regularly Maintained Political Science Data Sets.

This R package includes functions for gathering commonly used and regularly maintained data set in political science. 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.

psData

Version 0.2.1 CRAN Version Build Status CRAN Monthly Downloads CRAN Total Downloads

Started by Christopher Gandrud


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 political science literature, but are not regularly updated.

psData includes two primary function types: Getters and Variable Builders. Getter functions automate the gathering and cleaning of particular data sets so that they can easily be merged with other data. They do not transform the underlying data. Variable Builders use Getters to gather data and then transform it into new variables suggested by the political science literature. The functions currently part of psData include:

Getters

  • 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.

  • WB_IMFGet downloads Axel Dreher's data set of IMF programs and World Bank projects (1970-2011). It keeps specified variables and creates a standard country ID variable that can be used for merging the data with other data sets.

Variable Builders

  • 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.

Others

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.

Updates

Most of the Getter functions currently included in psData download data from a specific URL that links to a data file. Hopefully, the data sets' authors will keep their data up-to-date. When they make updates, they will likely link to the updated file with a new URL. All of the functions in psData that gather data from a file at a specific URL allow the user to specify a new URL, if they want to.

If you notice an updated version of one of the data sets, feel free to submit a Pull Request with the new URL. It would be great if you make sure that the function still works, as the data set's authors may change the format breaking the Getter function.

Suggestions

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.

Also feel free to make a pull request with a new Getter or Variable Builder. Please make the pull request on a branch other than the master.


Examples

To download only the polity2 variable from Polity IV:

library(psData)
PolityData <- PolityGet(vars = 'polity2')

head(PolityData)
##   iso2c standardized_country     country year polity2
## 1    AF          Afghanistan Afghanistan 1800      -6
## 2    AF          Afghanistan Afghanistan 1801      -6
## 3    AF          Afghanistan Afghanistan 1802      -6
## 4    AF          Afghanistan Afghanistan 1803      -6
## 5    AF          Afghanistan Afghanistan 1804      -6
## 6    AF          Afghanistan Afghanistan 1805      -6

Note that the iso2c variable refers to the ISO two letter country code country ID. This standardised country identifier could be used to easily merge the Polity IV data with another data set. Another country ID can be selected with the OutCountryID argument. See the package documentation for details.

To create winset (W) and selectorate (ModS) data use the following code:

library(psData)

WinData <- WinsetCreator()

head(WinData)
##   iso2c              country year    W ModS
## 1    AE United Arab Emirates 1975 0.25 0.25
## 2    AE United Arab Emirates 1976 0.25 0.25
## 3    AE United Arab Emirates 1977 0.25 0.25
## 4    AE United Arab Emirates 1978 0.25 0.25
## 5    AE United Arab Emirates 1979 0.25 0.25
## 6    AE United Arab Emirates 1980 0.25 0.25

Metadata

Version

0.2.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows