mlbgameday (version 0.0.1)

get_payload: Get Gameday data from MLBAM.

Description

Get Gameday data from MLBAM.

Usage

get_payload(start = NULL, end = NULL, league = "mlb", dataset = NULL,
  game_ids = NULL, db_con = NULL, ...)

Arguments

start

A start date passed as a character in ISO 8601 format. "2017-05-01"

end

An end date passed as a character in ISO 8601 format. "2017-09-01"

league

The league to gather gids for. The default is "mlb". Other options include "aaa" and "aa"

dataset

The dataset to be scraped. The default is "inning_all." Other options include, "inning_hit", "linescore".

game_ids

A list of user-supplied gameIds.

db_con

A database connection from the DBI package.

...

additional arguments

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# Make a request for a single day.
df <- get_payload(start = "2016-06-01", end = "2016-06-01")


# Run larger requests in parallel.
library(doParallel)
library(foreach)

no_cores <- detectCores() - 2
cl <- makeCluster(no_cores) 
registerDoParallel(cl)

df <- get_payload(start = "2016-01-01", end = "2017-01-01")

stopImplicitCluster()
rm(cl)

# }
# NOT RUN {
# Supply your own custom vector of game ids.

mygids <- search_gids(team = "indians", start = "2016-05-01", end = "2016-05-01")

df <- get_payload(game_ids = mygids)


# }

Run the code above in your browser using DataLab