View source: R/getRetrosheet.R
getRetrosheet | R Documentation |
This function downloads and parses data from https://www.retrosheet.org for the game-log, event, (play-by-play), roster, and schedule files.
getRetrosheet(
type,
year,
team,
schedSplit = NULL,
stringsAsFactors = FALSE,
cache = NA
)
type |
character. This argument can take on either of "game" for game-logs, "play" for play-by-play (a.k.a. event) data, "roster" for team rosters, or "schedule" for the game schedule for the given year. |
year |
integer. A valid four-digit year. |
team |
character. Only to be used if |
schedSplit |
One of "Date", "HmTeam", or "TimeOfDay" to return a list split by the given value, or NULL (the default) for no splitting. |
stringsAsFactors |
logical. The |
cache |
character. Path to local cache of retrosheet data. If file doesn't exist, files will be saved locally for future use. Defaults to "NA" so as not to save local data without explicit permission |
The following return values are possible for the given type
game
- a data frame of gamelog data for the given year
play
- a list, each element of which is a single game's play-by-play
data for the given team and year. Each list element is also a list, containing
the play-by-play data split into individual matrices.
roster
- a named list, each element containing the roster
for the named team for the given year, as a data frame.
schedule
- a data frame containing the game schedule for the given year
## get the full 1995 season schedule
getRetrosheet("schedule", 1995)
## get the same schedule, split by time of day
getRetrosheet("schedule", 1995, schedSplit = "TimeOfDay")
## get the roster data for the 1995 season, listed by team
getRetrosheet("roster", 1995)
## get the full gamelog data for the 2012 season
getRetrosheet("game", 2012)
## get the play-by-play data for the San Francisco Giants' 2012 season
getRetrosheet("play", 2012, "SFN")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.