library(ggplot2)
setwd("/Users/asherscott/Desktop/Data 110")
Polls <- read.csv("president_poll.csv")2016 Polling
This dataset came from the Fivethirtyeight 2016 Poll Data. I filtered the states to show only the top 15 most populated ones and used a scatter plot to where each poll had a candidate listed.
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Polls2 <- Polls %>%
filter(state %in% c("California", "Texas", "Florida", "Pennsylvania", "Illinois", "Ohio", "Georgia", "North Carolina", "Michigan", "New Jersey", "Virginia", "Washington", "Arizona", "Tennessee"))ggplot(Polls2, aes(x = state)) +
geom_point(aes(y = rawpoll_clinton, color = "Clinton")) +
geom_point(aes(y = rawpoll_trump, color = "Trump")) +
geom_point(aes(y = rawpoll_johnson, color = "Johnson")) +
geom_point(aes(y = rawpoll_mcmullin, color = "Mcmullin")) +
scale_color_manual(values = c("Trump" = "maroon", "Clinton" = "navyblue", "Johnson" = "forestgreen", "Mcmullin" = "orange")) +
labs(title = "2016 Polling Data in 15 States",
x = "States",
y = "Polling Percentage",
color = "Candidates") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))Warning: Removed 963 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 3567 rows containing missing values or values outside the scale range
(`geom_point()`).