-
Notifications
You must be signed in to change notification settings - Fork 10
/
README.Rmd
128 lines (89 loc) · 3.76 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "tools/README-",
cache.path = "README-cache/",
cache = TRUE,
message = FALSE
)
```
## United Nations General Assembly Voting Data
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/unvotes)](https://cran.r-project.org/package=unvotes)
[![Travis-CI Build Status](https://travis-ci.org/dgrtwo/unvotes.svg?branch=master)](https://travis-ci.org/dgrtwo/unvotes)
This package provides the voting history of countries in the [United Nations General Assembly](http://www.un.org/en/ga/), along with information such as date, description, and topics for each vote.
These come from the dataset [found here](https://dataverse.harvard.edu/dataset.xhtml?persistentId=hdl:1902.1/12379):
> Erik Voeten "Data and Analyses of Voting in the UN General Assembly" Routledge Handbook of International Organization, edited by Bob Reinalda (published May 27, 2013)
This raw data, and the processing script, can be found in the [data-raw](data-raw) folder.
### Installation
Install the package with:
```{r eval = FALSE}
install.packages("unvotes")
```
You can also install the development version of the package using [devtools](https://github.com/hadley/devtools):
```{r eval = FALSE}
devtools::install_github("dgrtwo/unvotes")
```
### Datasets
The package contains three datasets. First is the history of each country's vote. These are represented in the `un_votes` dataset, with one row for each country/vote pair:
```{r}
library(dplyr)
library(unvotes)
un_votes
```
The package also contains a dataset of information about each roll call vote, including the date, description, and relevant resolution that was voted on:
```{r}
un_roll_calls
```
Finally, the `un_roll_call_issues` dataset shows relationships betwen each vote and 6 issues:
```{r}
un_roll_call_issues
count(un_roll_call_issues, issue, sort = TRUE)
```
(Use `help()` to get information and documentation about each dataset).
### Example analysis
Many useful analyses will first involve joining the vote and roll call datasets by the shared `rcid` (roll call ID) column:
```{r joined}
library(dplyr)
joined <- un_votes %>%
inner_join(un_roll_calls, by = "rcid")
joined
```
One could then count how often each country votes "yes" on a resolution in each year:
```{r by_country_year, dependson = "joined"}
library(lubridate)
by_country_year <- joined %>%
group_by(year = year(date), country) %>%
summarize(votes = n(),
percent_yes = mean(vote == "yes"))
by_country_year
```
After which this can be visualized for one or more countries:
```{r by_country_year_plot, dependson = "by_country_year"}
library(ggplot2)
theme_set(theme_bw())
countries <- c("United States of America", "India", "France")
# there were fewer votes in 2013
by_country_year %>%
filter(country %in% countries, year <= 2013) %>%
ggplot(aes(year, percent_yes, color = country)) +
geom_line() +
ylab("% of votes that are 'Yes'")
```
Similarly, we could look at how the voting record of the United States has changed on each of the issues by joining with the `un_roll_call_issues` dataset:
```{r issue_plot, dependson = "joined", fig.height = 6, fig.width = 6}
joined %>%
filter(country == "United States of America") %>%
inner_join(un_roll_call_issues, by = "rcid") %>%
group_by(year = year(date), issue) %>%
summarize(votes = n(),
percent_yes = mean(vote == "yes")) %>%
filter(votes > 5) %>%
ggplot(aes(year, percent_yes)) +
geom_point() +
geom_smooth(se = FALSE) +
facet_wrap(~ issue)
```
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.