Created
December 8, 2018 21:08
-
-
Save WalkerHarrison/9758b7c9a0d861036daa0bc799760afd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pitch/play data scraped with pitchRx | |
pitches18 %>% | |
filter(type == 'X', | |
pitch_type == "FF") %>% | |
mutate(TB = case_when( | |
event == "Single" ~ 1, | |
event == "Double" ~ 2, | |
event == "Triple" ~ 3, | |
event == "Home Run" ~ 4, | |
TRUE ~ 0 | |
)) %>% | |
group_by(start_speed) %>% | |
summarize(SLG = mean(TB), | |
pitches = n()) %>% | |
filter(start_speed < 100, | |
start_speed > 90) %>% | |
ggplot(aes(start_speed, SLG, size = pitches)) + | |
geom_point() + | |
geom_smooth(method = 'lm', se = FALSE) + | |
guides(size = guide_legend(override.aes = list(linetype = 0))) + | |
labs(title = "SLG vs. Velocity, 2018", | |
subtitle = "(4-seam fastballs, balls in play)") + | |
theme_bw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment