setwd("/Users/isaiahjohnson/Desktop/Programming")
library(tidyverse)
batting<-read_csv("batting.csv")
HRhitters<-batting %>%
filter(HR>39) %>%
mutate(Era=cut(yearID,
breaks=c(1800,1900,1919,1941,1960,1976,1993,2005,2050),
labels=c("19th Century","Dead Ball","Lively Ball",
"Integration","Expansion","Free Agency","Steroid",
"Long Ball"
)))
ggplot(data=HRhitters,aes(x=Era))+
geom_bar(stat="Count")+
xlab("Era")+
ylab("Number of 40+ HR Hitters")+
ggtitle("Number of 40+ HR Hitters per Era")In Class Activity
Introduction
The question I will answer is which era of baseball had the most 40+ home run hitters?
To answer this question I will use the batting data from the Lahman database. First I will filter for players who have had a season over 39 home runs. Next I will create an era variable using the mutate function and label them. To find out what years are in what era I searched up all the eras in baseball. Next I will create a bar plot that shows the number of 40+ home run hitters in each era
Explanation
This graph shows the steroid era had the most 40+ home run hitters. A few things to note are that the 19th century era had no 40+ home run hitters. Also the steroid had the most years in their respected era. However, the steroid era by far had the most 40+ home run hitters as the next closest era did not even have over 75 40+ home run hitters.