Last active
August 29, 2015 14:04
-
-
Save cpsievert/53d6213011d08475a483 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
library(pitchRx) | |
data(gids, package = "pitchRx") | |
# Grab gameday identifiers for every Twin's home game in 2012 | |
min.gids <- gids[grepl("2012_[0-9]{2}_[0-9]{2}_[a-z]{6}_minmlb", gids)] | |
urls <- paste0(pitchRx:::gids2urls(min.gids), "/rawboxscore.xml") | |
library(XML2R) | |
obs <- XML2Obs(urls) | |
nms <- names(obs) | |
boxscore <- collapse_obs(obs[grepl("^boxscore$", nms)]) | |
attendance <- as.integer(gsub("\\,", "", boxscore[,"attendance"])) | |
hist(attendance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment