Tableau Assignment: Election Map 2000-2020

Election Map

For this assignment two maps will be made. The first map is a interactive choropleth map of United States counties. It will have several pages to filter by year to see how each county votes across the US. The second map will be the electoral college map for each election, focusing on the states. This map will indicate how the state votes as a whole and can help see which counties can have the most effect in a state.

For the first part of this assignment we will create two subsets from the presidentalelection_2000_2020 dataset. The data set contains the year, political party, state, county, and votes. The first dataset created, countydata, will hold the election results for each county. The second dataset will hold the results for each state level. In order to get this data prepared, the subsetted data must be grouped by the county and year. Then, only the highest canidate votes are kept to pick the winning party. For the state dataset, the same process follows, but instead of being grouped by county and year, it is state and year. The code to create these subsets is below:

library(lubridate) 

x <- getURL("https://jessgorr01.github.io/jGorrCV/wk9/PresidentialElection2000To2020.csv")
election <- read.csv(text = x)

#election <- read.csv('PresidentialElection2000to2020.csv')

election$party_participation <- (election$candidatevotes / election$totalvotes) *100

countydata <- election %>%
                group_by(county_name, year) %>%
                 slice(which.max(party_participation))




statedata <- election %>%
                group_by(state, year) %>%
                 slice(which.max(party_participation))

write.csv(countydata,'C:/Users/jessg/OneDrive - West Chester University of PA/sta553/wk9/countydata.csv')
write.csv(statedata,'C:/Users/jessg/OneDrive - West Chester University of PA/sta553/wk9/statedata.csv')

Now that the data has been subsetted, it is time to create the map in tableau.

County Map Analysis

When looking at the county maps, there is a clear distinction amoungst the population. In highly populated counties, the votes lean towards the Democratic Party, while in lesser populated counties the vote leans towards Republican.This can be seen nearly every election year.

State Map Analysis

When looking at the state election map, it protrays simimilarities to the counties. The east coast and California are Democatic for the most part. The main exception is Pennsylvania, which is a swing state. This can be seen from 2012 and 2016. The Mid-West and Western part of the US is mainly Republican. This can be due to smaller populations and way of life in these states.