---
title: "Ge05"
author: "Alicia Kiley"
date: "3/26/2018"
output: html_document
---

The purpose of this exercize was to mutate variables and use the map overlay once again to show trends by region.

Loading in the data and assigning objects.
```{r setup}
library(tidyverse)
all_states <- map_data("state")
congress<-read_csv("womenincongress.csv")
names(congress)[2] <- "region"
stateData <- left_join(all_states,congress,by="region")

stateData$repProp<-stateData$representatives/stateData$total

electionData <- read_csv("2012.csv")
names(electionData)[1] <- "region"

electionData$ObamaPerc <-electionData$ObamaVotes/(electionData$ObamaVotes+electionData$RomneyVotes+electionData$JohnsonVotes+electionData$SteinVotes)
electionData$RomneyPerc <-electionData$RomneyVotes/(electionData$ObamaVotes+electionData$RomneyVotes+electionData$JohnsonVotes+electionData$SteinVotes)

electionData <- merge(all_states,electionData,by="region")

South<-filter(electionData,region %in% c("delaware", "florida", "georgia", "maryland", "north carolina", "south carolina", "virginia", "district of columbia", "west virginia", "alabama", "kentucky", "mississippi", "tennessee", "arkansas", "louisiana", "oklahoma", "texas"))
```


#House Plot
```{r}
housePlot <- ggplot()+geom_polygon(data=stateData,aes(x=long, y=lat, group = group, fill=repProp),color="grey50")+
  coord_map()+labs(x="",y="",title="Women in the House")+theme_classic()+ 
  theme(axis.ticks.y = element_blank(),axis.text.y = element_blank(), axis.ticks.x = element_blank(),axis.text.x = element_blank())+
  scale_fill_gradient(name="Female Representatives",low="whitesmoke",high="darkred")
housePlot
```

#South Election Plot
```{r}
SouthelectionPlot<-ggplot()+geom_polygon(data=South,aes(x=long, y=lat, group = group, fill=ObamaPerc),color="grey50")+
  coord_map()+labs(x="",y="",title="2012 Election Results")+
  theme_classic()+ theme(axis.ticks.y = element_blank(),axis.text.y = element_blank(), axis.ticks.x = element_blank(),axis.text.x = element_blank()) + 
  scale_fill_gradient2(name="Obama's Percenatage",low="red",mid="white",high="blue",midpoint=.5)
SouthelectionPlot
```

