makeUrls: Construct Gameday urls based on some parameters.

View source: R/scrape.R

makeUrlsR Documentation

Construct Gameday urls based on some parameters.

Description

This is a convenience function (used by scrape) which constructs urls with the common Gameday root http://gd2.mlb.com/components/game/mlb/.

Usage

makeUrls(start, end, gids = "infer")

Arguments

start

date "yyyy-mm-dd" to commence scraping.

end

date "yyyy-mm-dd" to terminate scraping.

gids

The default value "infer" suggests gameday_links should be derived and appended appropriately (based on values of start and end). Otherwise, a character vector with gameday_links can be supplied.

Value

Returns a character vector.

Examples


# XML file names with pitch-by-pitch level data
prefix <- makeUrls(start="2011-04-04", end="2011-04-04")
paste0(prefix, "/inning/inning_all.xml")
# XML file names with hit location data
paste0(prefix, "/inning/inning_hit.xml")
# XML file names with game-by-game level data
paste0(makeUrls(start="2011-04-04", end="2011-04-04", gids=""), "/miniscoreboard.xml")
# Use gids option instead
data(gids)
identical(prefix, makeUrls(gids=gids[grep("2011_04_04", gids)]))


cpsievert/pitchRx documentation built on Aug. 19, 2023, 10:02 p.m.