knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
Here is a brief illustration of using the WinProbability package just created on my Github site.
Install the package from Github:
library(devtools) install_github("bayesball/WinProbability")
Load the package:
library(WinProbability)
I'm in a folder where I have a raw Retrosheet play-by-play datafile. Note that the file must be of the form allYEAR.csv
where YEAR is the value input in the function.
dir()
The compute.runs.expectancy
function:
d2018 <- compute.runs.expectancy(2018)
The compute.win.probs
function will
d2018 <- compute.win.probs(d2018)
The graph.game
function will plot the win probabilities for all plays in a specific game.
plays <- graph.game(d2018, "SLN201805190")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.