I wanted to see if the 2014 elections were different from other midterm elections by seeing how much Congress changed in comparison to the President’s party. I found data from Chapter Two of the Brookings Institute Vital Stats on Congress (section 4). I added 2014’s data and plotted two charts (house and senate) from here: http://www.presidency.ucsb.edu/data/mid-term_elections.php

First I read in a csv file with my data and named it “losses”. I kept getting error messages that had to do with the way my data was arranged so I looked up what the problem was and it turns out I needed to make my data into longform. I used the reshape2 package to do that.

I made a plot with “group” (because of the longform data), x and y, and made each line colored. Next is the years, using a continuous x scale Geom_line adds the actual line, and the rest is tinkering with theme and titles. I turned the year labels 90 degrees so they would be readable.

library(ggplot2)
library(ggthemes)
library(reshape2)

losses <- read.csv("Presidential_Midterm_Losses.csv", header = TRUE)
losseslong <- melt(losses, id = c("Year" , "Party"))

p <- ggplot(losseslong, aes(group = variable, x = Year, y = value , colour=variable)) + 
  scale_x_continuous(breaks=seq(1938, 2014, 4)) +
scale_y_continuous(breaks=seq(-80, 10, 10)) +
  geom_line() + 
  theme_tufte() +
  theme(axis.text.x = element_text(angle=90, size = 12),
        axis.text.y = element_text(size = 12, vjust = -.50), 
        axis.ticks.y = element_blank(),
        axis.text.y = element_blank(),
        legend.title = element_blank()) +
  labs (title = "Presidential Party Losses in Congress During Midterm Elections", y = "Losses in Congress for Presiden'ts Party", x = "Year") 
p

This chart shows that in 2014, the President’s party did not lose nearly as many seats as in previous years. In 2010 even, Democrats lost more seats in the house more than four times over – but this election made it the tipping point for a change in the majority. Another interesting segment was during Clinton’s administration, when the first midterm elections showed a huge loss for Democrats in the house and a major loss in the senate – but the second midterm in 1998 showed Democrat gains in the House and Senate.

This graph does not show percent of Democrats or Republicans – rather, it is trying to show that losses in Congress related to the President’s party during midterm elections is very common – and 2014 actually had relatively little loss. It was because of the heavy losses for House Dems in 2010 that 2014 offered the tipping point for a divided government.