In this exercise we will explore how various countries vote in the United Nations General Assembly. We will seek to answer how their voting patterns have evolved over time, and how similarly or differently do they view certain issues. Answering these questions (at a high level) is the focus of this analysis.
We will use the tidyverse, lubridate, and scales packages for data wrangling and visualization, and the DT package for interactive display of tabular output, and the unvotes package for the data.
library(tidyverse)
library(lubridate)
library(scales)
library(DT)
library(unvotes)
The data we’re using originally come from the unvotes package.
Let’s create a data visualisation that displays how the voting record of the three most populous countries, China, India, and the US changed over time on a variety of issues.
We can easily change which countries are being plotted by changing
which countries the code above filters for. Note that the
country name should be spelled and capitalized exactly the same way as
it appears in the data.
To see all the country names as they appear in the data, we will run the following code chunk:
The following code does some data preprocessing.
unvotes <- un_votes %>%
inner_join(un_roll_calls, by = "rcid") %>%
inner_join(un_roll_call_issues, by = "rcid")
The following code chink will make the plot.
unvotes %>%
filter(country %in% c("India", "United States", "China")) %>%
mutate(year = year(date)) %>%
group_by(country, year, issue) %>%
summarize(percent_yes = mean(vote == "yes")) %>%
ggplot(mapping = aes(x = year, y = percent_yes, color = country)) +
geom_point(alpha = 0.4) +
geom_smooth(method = "loess", se = FALSE) +
facet_wrap(~issue) +
scale_y_continuous(labels = percent) +
labs(
title = "Percentage of 'Yes' votes in the UN General Assembly",
subtitle = "1946 to 2015",
y = "% Yes",
x = "Year",
color = "Country"
) +
theme_bw()