2.6 Comparing Presidential vs. Midterm turnout

How does turnout compare in presidential vs. midterm years? Sometimes using a single summary of turnout may obscure important underlying differences in the data. To detect these differences, we may want to summarize different parts of the data.

Oh dear. We need to extract specific years from the turnout data frame. Which rows contain the years we want?

turnout$year
##  [1] 1980 1982 1984 1986 1988 1990 1992 1994 1996 1998 2000 2002 2004 2008

Ok: rows 1,3,5,7,9,11,13,14 are the presidential. And rows 2,4,6,8,10,12 are midterms.

## we can extract all of these at once by using c()
turnout$year[c(1,3,5,7,9,11,13,14)] # presidential
## [1] 1980 1984 1988 1992 1996 2000 2004 2008

Let’s take the mean VEP turnout for presidential years.

mean(turnout$newVEPturnout[c(1,3,5,7,9,11,13,14)])
## [1] 55.983

Let’s take the mean VEP turnout for midterm years.

mean(turnout$newVEPturnout[c(2,4,6,8,10,12)])
## [1] 39.5712

Let’s take the difference by storing each mean and then subtracting

mean.VEP.pres <- mean(turnout$newVEPturnout[c(1,3,5,7,9,11,13,14)])
mean.VEP.mid <- mean(turnout$newVEPturnout[c(2,4,6,8,10,12)])
mean.VEP.pres -  mean.VEP.mid
## [1] 16.41181

Presidential turnout, on average, is higher than midterm turnout.

2.6.1 R shortcut for writing vectors

Sometimes we write numbers that are in a predictable sequence (e.g., 1,2,3,4,5). In R, we have functions that prevent us from having to type each number when this is the case.

c(1,2,3,4,5) # is equivalent to:
## [1] 1 2 3 4 5
1:5 # is equivalent to:
## [1] 1 2 3 4 5
seq(from = 1, to = 5, by = 1)
## [1] 1 2 3 4 5

We can use the last one to our advantage to extract the midterm years, which go by 2

mean(turnout$newVEPturnout[c(2,4,6,8,10,12)]) # is the same as
## [1] 39.5712
mean(turnout$newVEPturnout[seq(2, 12, 2)])
## [1] 39.5712

Not a big deal now, but imagine if you had to write 100 numbers or 1 MILLION NUMBERS!

In this section, we have described voter turnout using multiple measures and types of elections. There are several other questions that political scientists may be interested in when it comes to voter turnout.

For example, Texas and more than a dozen other states have passed new laws that change voting procedures in elections. What effect will these have on voter turnout? In the next section, we start to examine how to evaluate causal claims.