Last active
August 29, 2015 14:03
-
-
Save cpsievert/a9fcfca600a9e46142d0 to your computer and use it in GitHub Desktop.
This file contains 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
devtools::install_github("cpsievert/pitchRx") | |
library(pitchRx) | |
library(dplyr) | |
dat <- scrape(start = "2013-09-01", end = "2013-09-11", | |
suffix = c("inning/inning_all.xml", "players.xml")) | |
# note that gameday_link can be used as a "game identifier" | |
p.data <- dat$pitch %>% | |
select(des, px, pz, sz_bot, sz_top, pitch_type, gameday_link, num) %>% | |
filter(des %in% c("Called Strike", "Ball")) | |
b.data <- dat$atbat %>% | |
select(b_height, stand, gameday_link, num) | |
u.data <- dat$umpire %>% | |
select(position, name, gameday_link) %>% | |
filter(position=="home") | |
pub <- p.data %>% merge(u.data, by = "gameday_link") %>% | |
merge(b.data, by = c("gameday_link", "num")) %>% | |
select(name, des, px, pz, sz_bot, sz_top, pitch_type, b_height, stand) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment