makeUrls: Construct Gameday urls based on some parameters.

Description Usage Arguments Value Examples

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)]))

Example output

Loading required package: ggplot2
[1] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_arimlb_chnmlb_1/inning/inning_all.xml"
[2] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_atlmlb_milmlb_1/inning/inning_all.xml"
[3] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_detmlb_balmlb_1/inning/inning_all.xml"
[4] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_minmlb_nyamlb_1/inning/inning_all.xml"
[5] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_pitmlb_slnmlb_1/inning/inning_all.xml"
[6] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_seamlb_texmlb_1/inning/inning_all.xml"
[1] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_arimlb_chnmlb_1/inning/inning_hit.xml"
[2] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_atlmlb_milmlb_1/inning/inning_hit.xml"
[3] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_detmlb_balmlb_1/inning/inning_hit.xml"
[4] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_minmlb_nyamlb_1/inning/inning_hit.xml"
[5] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_pitmlb_slnmlb_1/inning/inning_hit.xml"
[6] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_seamlb_texmlb_1/inning/inning_hit.xml"
[1] "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/miniscoreboard.xml"
[1] TRUE

pitchRx documentation built on May 2, 2019, 5:56 a.m.

Related to makeUrls in pitchRx...