get_payload: Get Gameday data from MLBAM.

Description Usage Arguments Examples

View source: R/get_payload.R

Description

Get Gameday data from MLBAM.

Usage

1
2
get_payload(start = NULL, end = NULL, league = "mlb", dataset = NULL,
  game_ids = NULL, db_con = NULL, overwrite = FALSE, ...)

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.

overwrite

Logical. Should current database be overwritten? Inherited from the dbWriteTable function from the DBI package. The default value is FALSE.

...

additional arguments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## 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)


## End(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)

keberwein/mlbgameday documentation built on May 17, 2019, 12:14 p.m.