Skip to content

Instantly share code, notes, and snippets.

@byanuaria
Created August 29, 2018 19:34
Show Gist options
  • Save byanuaria/9fca7bcf265d4278578ccf4437cbfd3b to your computer and use it in GitHub Desktop.
Save byanuaria/9fca7bcf265d4278578ccf4437cbfd3b to your computer and use it in GitHub Desktop.
library(pitchRx)
library(tidyverse)
data <- scrape(start = "2011-04-04", end = "2011-06-01")
pitches <- data[["pitch"]]
ab <- data[["atbat"]]
newDat <- merge(pitches, ab, by = c("num", "gameday_link"))
newDat <- newDat[1:95]
newDat <- newDat %>%
select(num, des, sz_top, sz_bot, px, pz,
pitch_type, zone, count, pitcher, batter,
b_height)
isoCounts <- noSwing %>%
filter(count %in% c("0-2", "1-2", "2-2", "3-0", "3-1", "3-2"))
isoCounts <- isoCounts %>%
select(des, sz_top, sz_bot, px, pz, count) %>%
mutate(PZ = (pz - sz_bot) / (sz_top - sz_bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment