Collection of R Commands
# We can save this as a script to run later
library(Lahman)
library(tidyverse)
crcblue <- "#2905a1"
ws <- SeriesPost |>
filter(yearID >= 1903, round == "WS", wins + losses < 8)
ggplot(ws, aes(x = wins + losses)) +
geom_bar(fill = crcblue) +
labs(x = "Number of games", y = "Frequency")
# running the script
source(here::here("scripts/WorldSeriesLength.R"), echo = TRUE)
##
## > library(Lahman)
##
## > library(tidyverse)
##
## > crcblue <- "#2905a1"
##
## > ws <- filter(SeriesPost, yearID >= 1903, round ==
## + "WS", wins + losses < 8)
##
## > ggplot(ws, aes(x = wins + losses)) + geom_bar(fill = crcblue) +
## + labs(x = "Number of games", y = "Frequency")

source(here::here("scripts/hr_rates.R"))
# Mickey Mantle stats ffrom 1951 to 1961
HR <- c(13, 23, 21, 27, 37, 52, 34, 42, 31, 40, 54)
AB <- c(341, 549, 461, 543, 517, 533, 474, 519, 541, 527, 514)
Age <- 19 : 29
hr_rates(Age, HR, AB)
## $x
## [1] 19 20 21 22 23 24 25 26 27 28 29
##
## $y
## [1] 3.8 4.2 4.6 5.0 7.2 9.8 7.2 8.1 5.7 7.6 10.5