Learn R Programming

OpenWAR

An open-source system for computing Wins Above Replacement

This package is designed to present a reference implementation of Wins Above Replacement for Major League Baseball players.

Installation

The Sxslt package is required in order to download new game data from MLBAM. This package is not present on CRAN. Hence, some manual installation may be necessary. The following command:

install.packages("Sxslt", repos = "http://www.omegahat.org/R", type = "source")

should do the trick.

Next, installing openWAR is best accomplished through the install_github() function in the devtools package.

require(devtools)
install_github("beanumber/openWAR")

Data Source

The gameday() function downloads play-by-play data from the GameDay server hosted by Major League Baseball Advanced Media. This data is not libre, but it lives on a publicly-available webserver.

Getting individual game data is as simple as:

library(openWAR)
gd <- gameday()
summary(gd)

To retrieve a data.frame of many games worth, try:

ds <- getData()

This will retrieve play-by-play data for all games played yesterday (by default). For each play, 62 variables are recorded.

Methodology

Please see our full paper on the arXiv or in the forthcoming issue of the Journal of Quantitative Analysis in Sports.

Copy Link

Version

Version

0.2.2.9001

License

GPL (>=2)

Issues

Pull Requests

Stars

Forks

Maintainer

Ben Baumer

Last Published

July 19th, 2018

Functions in openWAR (0.2.2.9001)

GameDayPlaysExt-class

GameDayPlaysExt
GameDayPlaysExt

GameDayPlaysExt
GameDayPlays

GameDayPlays
getGameIds

getGameIds
getFielderResp

getFielderResp
getFielderRAA

getFielderRAA
getFielderId

getFilederId
getData

getData
gameday

gameday
GameDayPlays-class

GameDayPlays
getModelFieldingCollective

getModelFieldingCollective
getRunnerMovement

getRunnerMovement
getReplacementMeans

getReplacementMeans
getRunEx

getRunEx
getModelRunExpectancy

getModelRunExpectancy
getURLs.gameday

getURLs.gameday
getModels

getModels
getReplacementActivity

getReplacementActivity
getReplacementPlayers

getReplacementPlayers
getRAA

getRAA
May

A month-long sample of GameDayPlays data from MLBAM
MetsBraves

A sample of play-by-play data from MLBAM
makeSubstitutions

make substitutions
makeWARre24

makeWARre24
getWAR

getWAR
makeWARBaserunning

makeWARBaserunning
makeWARFielding

makeWARFielding
May14

A day-long sample of GameDayPlays data from MLBAM
MayProcessed

makeWAR

makeWAR
plot.gameday

panel.baseball
openWAR

openWAR
openWARPlayers

openWARPlayers
openWARPlays

openWARPlays
panel.war

panel.war
plot.do.openWARPlayers

plot.do.openWARPlayers
mosaic.do

mosaic.do
openWARPlays-class

openWARPlays
openWARPlayers-class

openWARPlayers
openWAR2012

Final openWAR values for 2012.
summary.GameDayPlays

summary.GameDayPlays
plot.openWARPlayers

plot.openWARPlayers
tabulate

tabulate
readData.gameday

get game data
updateGame

updateGame
summary.openWARPlayers

summary.openWARPlayers
shakeWAR

shakeWAR
summary.do.openWARPlayers

summary.do.openWARPlayers
updateHalfInning

updataHalfInning