-
Notifications
You must be signed in to change notification settings - Fork 10
/
README.Rmd
99 lines (61 loc) · 5.29 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning = FALSE,
message = FALSE,
tidy = "styler",
fig.path = "man/figures/README-",
dpi = 90,
out.width = "100%"
)
```
# psData <a href='https://ropengov.github.io/psData/'><img src='man/figures/logo.png' align="right" height="139" /></a>
<!-- badges: start -->
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](http://ropengov.org/)
[![CRAN Version](http://www.r-pkg.org/badges/version/psData)](https://CRAN.R-project.org/package=psData)
[![R-CMD-check](https://github.com/rOpenGov/psData/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rOpenGov/psData/actions/workflows/R-CMD-check.yaml)
![CRAN Monthly Downloads](http://cranlogs.r-pkg.org/badges/last-month/psData)
![CRAN Total Downloads](http://cranlogs.r-pkg.org/badges/grand-total/psData)
<!-- badges: end -->
Started by Christopher Gandrud
---
This [R](https://www.r-project.org/) 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](https://www.iadb.org/en/research-and-data/publications?pub_id=IDB-DB-121) 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](http://www.systemicpeace.org/polity/polity4.htm) 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)](https://carmenreinhart.com/browse-by-topic/) crisis dummy variables into one data frame.
- `WB_IMFGet` downloads [Axel Dreher's data set of IMF programs and World Bank projects](http://www.uni-heidelberg.de/fakultaeten/wiso/awi/professuren/intwipol/datasets_en.html) (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)](https://doi.org/10.7551/mitpress/4292.001.0001) 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](https://github.com/vincentarelbundock/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](https://help.github.com/articles/using-pull-requests) 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](https://github.com/rOpenGov/psData/issues).
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](http://www.systemicpeace.org/polity/polity4.htm):
```{r, message=FALSE, warning=FALSE}
library(psData)
PolityData <- PolityGet(vars = 'polity2')
head(PolityData)
```
Note that the **iso2c** variable refers to the [ISO two letter country code country ID](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). 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:
```{r, message=FALSE, warning=FALSE}
library(psData)
WinData <- WinsetCreator()
head(WinData)
```
---