On a recent FiveThirtyEight Politics Podcast the hosts discussed ranked-choice voting in the Maine primary elections, and the difficulty of explaining the process to voters. While ranked-choice voting is far from simple, I think part of the complexity comes from the either obscure names of third-tier politicians or the arbitrary theoretical examples we use. If we had a popular example where many people have created a ranked list of options then the explanation of the method might be more tangible.
My latest blog post covered using Ranked-Choice voting and reddit user rankings to determine the (second) best Black Mirror Episode. The key visualization was the Sankey diagram, and in this vignette I’ll walk through my R code for how the chart was made.
Libraries and Packages library(tidyverse) library(forcats) library(magrittr) library(knitr) library(alluvial) library(ggalluvial) library(extrafont) colortable <- read_csv("c:/Users/blaze/Documents/R_Projects/BlackMirror/color_palette.csv") Lots of packages here:
Tidyverse - all encompassing package for data manipulation and visualization forcats - enables better ordering of factor variables (episode names) when plotting magrittr - I did some in-line code, and magritter has some functions like multiply_by() that allow you to perform arithmetic in a %>% pipeline knitr - For kable tables extrafont - Loading of other fonts alluvial - necessary for Sankey plots ggaluvial - enables Sankey plots Also I have my color palette for each episode.