Skip to content

Instantly share code, notes, and snippets.

@WalkerHarrison
Created December 8, 2018 21:08
Show Gist options
  • Save WalkerHarrison/9758b7c9a0d861036daa0bc799760afd to your computer and use it in GitHub Desktop.
Save WalkerHarrison/9758b7c9a0d861036daa0bc799760afd to your computer and use it in GitHub Desktop.
# 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