09 April 2016

Wisconsin presidential primary

I was curious about the Wisconsin primary election results. I wanted to see how the votes stacked up among Democrats and Republicans. I also wanted to see how both parties compared to the number of eligible voters that didn’t vote.

I downloaded election results from WisconsinVote.org on 8 April 2016. According to Wisconsin’s Government Accountability Board, the State of Wisconsin has 4.44 million eligible voters, of which 3.39 million were registered by 1 April 2016.

Democrat Didn’t Vote Republican
Sanders 567,936 0 0
Clinton 432,767 0 0
Other Dem. 3,201 0 0
No Vote 0 2,334,973 0
Cruz 0 0 531,129
Trump 0 0 386,370
Kasich 0 0 155,200
Other Rep. 0 0 28,424



Are we so accustomed to low voter turn out, that we no longer see the elephant in the room - the large number of eligible voters that don't participate in the elections at all?



My primary (ha!) interest in this topic was not coding, but I provide the R script that I used below.
# enter the data
dat2 <- data.frame(
  Democrat = c(567936, 432767, 3201, 0, 0, 0, 0, 0), 
  `Didn't Vote` = c(0, 0, 0, 2334973, 0, 0, 0, 0), 
  Republican = c(0, 0, 0, 0, 531129, 386370, 155200, 28424), 
  row.names = c("Sanders", "Clinton", "Other Dem.", "No Vote", 
    "Cruz", "Trump", "Kasich", "Other Rep."),
  check.names=FALSE)

# prepare colors for bars
library(RColorBrewer)
n <- apply(dat2>0, 2, sum)
colz <- c(rev(brewer.pal(n[1], "Blues")), "gray", rev(brewer.pal(n[3], "Reds")))

# initial plot
par(mar=c(4, 4, 1, 4))
x <- barplot(as.matrix(dat2), col=colz, yaxt="n", 
  xlab="Chosen Primary Party", ylab="Eligible Voters  (millions)")

# add axes
tix <- seq(0, 5, 0.25)
axis(2, at=tix*1e6, labels=format(tix), las=1)
tix2 <- seq(0, 100, 5)
axis(4, at=4.44e6*tix2/100, labels=format(tix2), las=1)
mtext(side=4, "Eligible Voters  (%)", line=3)

# add labels to bars
barlabx <- rep(x, n)
barlaby <- apply(dat2, 2, function(y) {
  y2 <- y[y>0]
  cumsum(y2) - y2/2
})
barlab <- c("Sanders", "Clinton", "", "", "Cruz", "Trump", "Kasich", "")
text(barlabx, unlist(barlaby), barlab, col="white", font=2)

No comments:

Post a Comment