Data Driven Animation
Introduction
For this project, I will create a data driven animation to tell the story about the rise and fall of autocratic ruling parties around the world from 1940-2015.
The dataset has been created by Michael K. Miller, an Associate Professor of Political Science and International Affairs from George Washington University. You can find more about the data here.
# Load Libraries
library(tidyverse)
library(ggmap)
library(maps)
library(ggthemes)
library(gganimate)
library(viridis)
Data Preparation
The Autocratic Ruling Parties Dataset (ARPD) includes a range of variables for all autocratic ruling parties in the world from 1940-2015. The data covers 479 total autocratic regime spells. This corresponds to 156 countries (including microstates) and 133 countries with at least one ruling party spell.
# Load dataset
data <- read.table("https://raw.githubusercontent.com/saayedalam/Data/master/AutocraticRulingPartiesDataset_cy.txt")
dim(data)
## [1] 6536 40
Overview And Sample
The following excerpts from the author of the dataset eloquently and elaborately describe the nature of this dataset:
The sample includes any ruling party that had power between 1940 and 2015 within an autocracy, with autocracy defined using Boix et al.’s (2013) most recent update. A ruling party is defined as a political party that is either the supreme ruling power or is used as a significant vehicle of power by the regime and is clearly preeminent among all parties. Where there is any ambiguity, special attention is placed on parties of the executive. The sample therefore includes military regimes, monarchies, and personalistic regimes, as long as the rulers rely to a meaningful degree on a specific party. Cases where there are multiple parties in a legislature or lower-level government, fluid competition, and little to no reliance on parties by a monarch or military dictator (e.g., modern Morocco, Japan in the 1930s) are not included. Parties founded to compete in democratizing elections and parties of the executive in caretaker governments before a democratic transition are also not counted.
The dataset tracks continuous party spells in power. A breakdown is recorded if there is a transfer of power to a distinct party, a transition to a non-party autocratic regime, or democratization. Major splits and mergers are treated as breakdowns, but not changes in name, policy, or when a ruling party absorbs a small party without fundamental change (e.g., the Workers’ Party of North Korea’s merger with its outlawed South Korean sibling in 1949). Where any change occurred, the cases were checked to ensure the same organization and power structure remained in place.
Each year in each autocracy is assigned to a ruling party or non-party government. If am transition occurs, the regime at the year’s end is generally applied to that year. However, if a party gains power, rules for most of the year, then loses power before the year’s end, the year is assigned to that party to avoid omitting it entirely. In addition, if a party loses power and there’s a short non-party transitional spell crossing into the following year, the year is assigned to the party rather than a non-party interruption. Autocratic years without a party are included with missing values for party characteristics and indicators for the predominant form of regime during the period.
set.seed(123)
data %>%
sample_n(5)
## Country ccode Year Party_Regime
## 1 Honduras 91 1964 1
## 2 Hungary 310 1970 1
## 3 Guinea 438 1970 1
## 4 Benin 434 1962 1
## 5 Nigeria 475 1995 0
## Party Year_Founded Party_Age
## 1 National Party of Honduras 1902 62
## 2 Hungarian Socialist Workers' Party 1956 14
## 3 Democratic Party of Guinea-African Democratic Rally 1947 23
## 4 Dahomeyan Unity Party 1960 2
## 5 N NA NA
## Year_in_Power Last_Year_of_Power Power_Change Competition Origin
## 1 1963 1970 0 1 Elite Coalition
## 2 1956 1989 0 0 Communist
## 3 1958 1983 0 0 Independence
## 4 1960 1962 1 0 Merger
## 5 1993 1998 0 NA <NA>
## How_Power_Gained How_Power_Ended Democracy_Year_After Accession_to_Democracy
## 1 Military Continued 1 1
## 2 Communist-Imposed Election 1 1
## 3 Election Coup 0 0
## 4 Election Coup 0 0
## 5 <NA> <NA> 0 0
## Power_from_Independence Renaming Evolution Marxist Military Monarchy Violence
## 1 0 <NA> 0 0 0 0 0
## 2 0 <NA> 1 1 0 0 0
## 3 1 <NA> 0 1 0 0 0
## 4 1 <NA> 0 0 0 0 0
## 5 NA <NA> NA NA 1 0 0
## Occupation Compet_Auth Compet_Parties Last_Before_Dem Next_Dem_Year
## 1 0 0 <NA> 1 1971
## 2 0 0 <NA> 1 1990
## 3 0 0 <NA> NA NA
## 4 0 0 <NA> 0 1991
## 5 0 0 <NA> NA NA
## Dem_Remains Dem_Competitive Dem_Power Dem_Remains_Any Dem_Competitive_Any
## 1 1 1 1 1 1
## 2 1 1 1 1 1
## 3 NA NA NA NA NA
## 4 0 0 0 0 0
## 5 NA NA NA NA NA
## Dem_Power_Any Dem_Years_Remains Dem_Years_Competitive
## 1 1 1971, 1982-2008, 2010-2015 1971, 1982-2008, 2010-2015
## 2 1 1990-2015 1990-2015
## 3 NA <NA> <NA>
## 4 0 <NA> <NA>
## 5 NA <NA> <NA>
## Dem_Years_Power Military_Ally Governance
## 1 1971, 1989-1993, 2001-2005, 2010-2015 1 Repressive
## 2 1994-1998, 2002-2010 1 Policy-Based/Repressive
## 3 <NA> NA <NA>
## 4 <NA> NA <NA>
## 5 <NA> NA <NA>
## Favors_Ethnic
## 1 0
## 2 0
## 3 NA
## 4 1
## 5 NA
Now that we understand the dataset, I will clean and transform the data according to the goal of this project. The goal is to show change in the number of autocratic regimes around the world over time.
- First, I will filter the dataset using the Party_Regime variable. This variable is 1 if the country has an autocratic ruling party and 0 otherwise.
- Next, I only select the variables Country and Year and add the number of parties per country per year.
- Then, using the ggmap package and Google Map API (API is hidden due to security. Read More), I extract the geolocation of all the countries.
- Finally, I join the dataset and print the first 5 rows of the clean dataset.
dt <- data %>%
filter(Party_Regime == 1) %>%
select(Country, Year) %>%
add_count(Year, name = "Party_Per_Year") %>%
mutate(Year = as.factor(Year))
longlat <- dt %>%
distinct(Country) %>%
mutate(Country = as.character(Country)) %>%
mutate_geocode(Country)
dt <- longlat %>%
right_join(dt)
head(dt)
## # A tibble: 6 x 5
## Country lon lat Year Party_Per_Year
## <chr> <dbl> <dbl> <fct> <int>
## 1 Afghanistan 67.7 33.9 1974 64
## 2 Afghanistan 67.7 33.9 1975 70
## 3 Afghanistan 67.7 33.9 1976 72
## 4 Afghanistan 67.7 33.9 1977 73
## 5 Afghanistan 67.7 33.9 1978 75
## 6 Afghanistan 67.7 33.9 1979 75
Data Visualization
Now that we have a clean dataset, it is time to visualize. First, I will create a layer of map borders using ggplot2 package.
world <- ggplot() +
borders("world", colour = "#81cffc", fill = "#b3e3ff") +
theme_map()
world
Next, I overlay the data points i.e. the number of parties per country. I use the virdis package to visualize the continuous variable of the number of parties.
map <- world +
geom_point(aes(x = lon, y = lat, colour = Party_Per_Year), data = dt, size = 7) +
scale_color_viridis() +
theme(legend.position = 'right') +
labs(title = "Autocratic Party Regimes", subtitle = "1940-2015", colour = "Number of Parties")
map
Animation
Finally, I animate the static graph in order to show the change in the number of parties from 1940 to 2015.
anime <- map +
labs(subtitle = "Year: {frame_time}") +
transition_time(as.integer(as.character(dt$Year))) +
shadow_wake(wake_length = 0.1) +
enter_grow() +
exit_shrink()
anime
Conclusion
The purpose of this data visualization project was to utilize animation techniques to tell the story of the rise and fall of autocratic regimes party. The animation tells us the rise of autocratic regimes started in Africa and parts of Europe and Asia in small numbers. Then we see parties showing up in parts of Central America and other parts of the American continents. We also see the highest number of parties in 1980s around the world. Finally, the parties started to disappear in the beginning of 21st century, first from Western hemisphere and then Europe. With some remaining in parts of Africa and Asia.