Is Iowa gerrymandered?

Iowa is proud of the non-partisan method we use to set our senate and house districts.  But the evidence suggests some gerrymandering may be present.  See the two plots below.

The two plots show the proportion of votes candidates received and the proportion of legislators elected to the statehouse in 2018 for three classes – Democrats, Republicans, and others.

The source of the Iowa voter data is at  The R function to extract the data for the House is

function( fl="canvsummary.xlsx" ){

    res=vector( mode="list", length=0 ) 
     for ( i in 88:187 ){
         re = read_xlsx( fl, sheet=i )
         nre = colnames( re )
         re = unlist( as.numeric( re[ nrow( re ), ] ) )
         names( re ) = nre
         print( re )
         res[[i-87]] = re 

For the Senate, ’88:187′ is replaced by ’63:87′ and ‘i-87’ by ‘i-62’.

The source for the numbers of legislators in the House is  The row for Iowa is 15. The House data is in columns 8 to 10.

For the Senate, the numbers can be found at  Only half of the senate is elected in any general election.  In 2018, senators of the odd numbered districts were elected.

The R function I used to create the plots for the House was

function( ds=ia.hou.8.7.19, n=100, id=8, lscn=Legis_Control_112118_26973_8_7_19[15,], ch="Iowa House 2018 Election" ){

sm = c( 0, 0, 0 )
names( sm ) = c( "DEM", "REP", "OTHER" )
for ( i in 1:n){
ei = which( grepl( "Write", names( ds[[i]] ) ) )
di = which( grepl( "DEM", names( ds[[i]] ) ) )
ri = which( grepl( "REP", names( ds[[i]] ) ) )
if( length( di )>0 ) sm[1]=sm[1]+ds[[i]][di]
if( length( ri )>0 ) sm[2]=sm[2]+ds[[i]][ri]
sm[3] = sm[3] + sum( ds[[i]][ ( max( di, ri )+1 ):ei ] )
print( sm )
par( mfrow=c(1,2), oma=c(2,1,1,1) )
pie( sm, labels=names( sm ), main="Votes", col=c("blue","red","tan"))

lscn[ lscn )==T ] = 0
print( lscn[ id:(id+2) ] )
pie( as.numeric( lscn[ id:(id+2) ] ), labels=names( sm ), 
main="Legislature", col=c( "blue","red","tan" ) )
mtext( ch, side=1, outer=T, cex=2, font=2 )

For the Senate, there were 12 Democrats  and 13 Republicans elected, which were the numbers used in the plot.

I used the program ‘smallpdf’ to convert the pdf’s to Excel spreadsheets, which I accessed using R Studio.  The R code for the legislative file was

Legis_Control_112118_26973_8_7_19 <- read_excel("Legis_Control_112118_26973.8.7.19.xlsx", sheet = "Table 2", col_names = FALSE, skip = 0)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s