## -- Attaching packages ---------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
sports<-read.csv("https://raw.githubusercontent.com/kitadasmalley/FA2020_DataV
iz/main/data/NFL_fandom_data.csv",
header=TRUE)
sportsT<-sports%>%
gather("sport", "searchInterest",-c(DMA, PctTrumpVote))
sportsT$sport<-factor(sportsT$sport,
level=c("NBA", "MLB", "NHL", "NFL", "CBB", "NASCAR", "CFB"))
ggplot(sportsT, aes(PctTrumpVote, searchInterest))+
geom_point(alpha=0.5)+
geom_smooth(method=lm, se = F)+
facet_wrap(~sport, nrow=1) +
labs(x = "Trump Vote Share", y = "Search Interest", title = "Donald Trump's 2016 vote share compared with search interest for \n seven major sports, by media market", caption = "Search interest based on Google Trends data from 2012 to 2017")+
ylim(0, .5)+
theme_minimal()+
theme(axis.text.x = element_blank())
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 11 rows containing non-finite values (stat_smooth).
## Warning: Removed 11 rows containing missing values (geom_point).
ggsave("Recreation.pdf", width = 8, height = 4)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 11 rows containing non-finite values (stat_smooth).
## Warning: Removed 11 rows containing missing values (geom_point).
ggplot(sportsT, aes(PctTrumpVote, searchInterest, group = sport))+
geom_boxplot(alpha=0.5)+
labs(x = "Trump Vote Share", y = "Search Interest")+
ylim(0, .5)+
theme_minimal()+
theme(axis.text.x = element_blank())
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
# Boxplot really didn’t do what I wanted it to do, so I’m moving on
ggplot(sportsT, aes(PctTrumpVote, searchInterest, color=sport)) +
geom_smooth(method=lm, se = F)+
scale_color_manual(values = c(NBA = "blue", MLB =
"blue", NHL = "blue", NFL = "purple", CBB = "red", NASCAR = "red", CFB = "red"))+
labs(x = "Trump Vote Share", y = "Search Interest", title = "Donald Trump's 2016 vote share compared with search interest for \n seven major sports, by media market", caption = "Search interest based on Google Trends data from 2012 to 2017")+
theme_minimal()
## `geom_smooth()` using formula 'y ~ x'
ggsave("New Version.pdf", width = 8, height = 4)
## `geom_smooth()` using formula 'y ~ x'