Intro to the unvotes package

knitr::opts_chunk$set(message = FALSE, warning = FALSE,
                      fig.height = 5, fig.width = 5)

This package provides the voting history of countries in the United Nations General Assembly, along with information such as date, description, and topics for each vote.


The unvotes contains three datasets, each data frames (specifically tbl_dfs, which are more convenient to print). 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:



The package also contains a dataset of information about each roll call vote, including the date, description, and relevant resolution that was voted on:


Finally, the un_roll_call_issues dataset shows relationships between each vote and 6 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:


joined <- un_votes %>%
  inner_join(un_roll_calls, by = "rcid")


One could then count how often each country votes "yes" on a resolution in each year:


by_country_year <- joined %>%
  group_by(year = year(date), country) %>%
  summarize(votes = n(),
            percent_yes = mean(vote == "yes"))


After which this can be visualized for one or more countries:


countries <- c("United States", "United Kingdom", "India", "France")

by_country_year %>%
  filter(country %in% countries) %>%
  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:

joined %>%
  filter(country == "United States") %>%
  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)

Try the unvotes package in your browser

Any scripts or data that you put into this service are public.

unvotes documentation built on March 9, 2021, 9:08 a.m.