################################################################################## ######## CREATES APPENDIX FIGURE A6 ################################################################################## dir <- paste(getwd(), "/Chen_Replication_Code",sep="") dir.create(dir) print(paste("ALL REPLICATION CODE WILL BE DOWNLOADED TO THE FOLLOWING FOLDER:",dir)) ##DOWNLOAD THE REPLICATION DATA FOR NON-COMPACT SIMULATIONS, IF NECESSARY NonCompactFolder <- paste(dir, "/FL_Simulations_NonCompact",sep="") st <- "FL" library(foreign) i <- 25 dbffile <- paste(NonCompactFolder,"/",st,".dbf",sep="") dbf <- read.dbf(dbffile) swrepvote <- sum(dbf$mccain, na.rm=TRUE) / (sum(dbf$mccain, na.rm=TRUE) + sum(dbf$obama, na.rm=TRUE)) BushVoteShare <- swrepvote sharesfile <- "http://www.umich.edu/~jowei/UnintentionalGerrymandering/FL25noncompact.txt" ##sharesfile <- paste("C:/Research/Dropbox/SimulationsNoncompact/FL/2000vote/plans","/",i,".txt",sep="") x <- read.table(sharesfile)##[1:25,] x1 <- x[,4:dim(x)[2]] repseats <- apply(x1, 1, function(x) sum(x>BushVoteShare)) medians <- apply(x1, 1, function(x) median(x)) sim <- 1:length(repseats) w <- as.data.frame(cbind(sim,repseats, medians)) w <- w[1:250,] ##PLOT THE NON-COMPACT SIMULATIONS xl <- c(10,20) lm <- 5 par(mar=c(5.5,lm,5,0.1)) plot(rep(0,dim(w)[1])~w$repseats, xlim=xl, ylim=c(3,100), type="n",bty="n", ylab="", xaxt="n", yaxt="n",xlab="") title(xlab="", mgp=c(4.25, 1.70, 0)) axis(1,at=seq(1:25),labels=paste(seq(1:25),"\n(", seq(1:25)/0.25 ,"%)",sep="") , mgp=c(2.5, 1.70, 0), cex.axis=0.79) axis(2,at=c(0,20,40,60,80,100),labels=c(0,20,40,60,80,100) , mgp=c(2.5, 1.0, 0), cex.axis=1) z <- summary(as.factor(w$repseats)) t <- 0.25 for (i in 1:length(names(z))){ s <- as.numeric(names(z)[i]) rect(s-t,0,s+t, as.numeric(z[i]) ) } ##lines(c(12.5,12.5),c(-100,100),lty="dashed") title(main="Partisan Bias Among 250 Non-Compact Simulations \nof Florida's Congressional Delegation (25 Districts)", xlab="Number of Bush-Leaning Districts\n(Percent out of 25 Total Congressional Districts in Florida)", mgp=c(4.25, 1.70, 0)) title(ylab="Frequency Among Simulated Districting Plans\n(250 Total Simulated Plans)", mgp=c(2.8, 1.0, 0))