AE 01 - United Nations Votes

My first Quarto file

Author

Dr. Donatello

Published

August 27, 2026

Introduction

How do various countries vote in the United Nations General Assembly, how have their voting patterns evolved throughout time, and how similarly or differently do they view certain issues? We’re going to start to answer these questions while learning about Quarto files.

NoteFollow Along
  1. Log into JupyterHub (will go through SSO)
  2. Launch Server
  3. Navigate to the shared/Donatello DATA 385 folder on the landing page
  4. Right click and “copy” the ae01-unvotes.qmd file.
  5. Navigate back up to your home directory, right click and “paste” this file.
  6. Start RStudio, then open this ae01-unvotes.qmd file from the lower right ‘files’ pane.
  7. Click the “Render” button on the top.
  8. Make the right side window tall and compare what you see left to right.
WarningYour Turn

Update the YAML header by

  1. Change to your name
  2. add date: today
  3. Re-render to see your changes

Packages

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)

Data

The data we’re using originally come from the unvotes package. In the chunk below we modify the data by joining the various data frames provided in the package to help you get started with the analysis.

unv <- unvotes::un_votes %>%
  inner_join(un_roll_calls, by = "rcid") %>%
  inner_join(un_roll_call_issues, by = "rcid")
WarningYour Turn

Examine the last two code chunks and figure out how to turn off the messages and warnings in the code chunk above.

UN voting patterns

Let’s create a data visualization that displays how the voting record of the UK & NI changed over time on a variety of issues, and compares it to two other countries: US and Turkey.

unv %>%
  filter(country %in% c("United Kingdom", "United States", "Turkey")) %>%
  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 2019",
    y = "% Yes",
    x = "Year",
    color = "Country"
  )

WarningYour Turn

Write 1-2 sentences here about what you learned from these plots.

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. See the Appendix for a list of the countries in the data.

WarningCustomize the plot

Choose different countries to explore. Copy the entire code chunk from above to below this line, edit the chunk label to make it unique, edit the countries and re-render. Write a few sentences comparing these countries to the ones above.

WarningExporting your file for submission
  1. Change the format type in the YAML header to pdf
  2. Delete the Appendix below (this is a html specific table)
  3. Render your document and review the PDF to make sure it looks complete.
  4. In the files tab, click the box next to the PDF for the file you want to export.
  5. Click “More” –> “Export”

This file will download to your computer. Submit to Canvas for credit.

References

  1. David Robinson (2017). unvotes: United Nations General Assembly Voting Data. R package version 0.2.0.
  2. 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).
  3. Much of the analysis has been modeled on the examples presented in the unvotes package vignette.

Appendix

Below is a list of countries in the dataset:

unv %>%
  select(country) %>%
  arrange(country) %>%
  distinct() %>%
  datatable()