The sabr package connects the Lahman SQL Database with functions used in calculating offensive performance in the MLB, namely wOBA. Created by Tom Tango and popularized in The Book: Playing the Percentages in Baseball, wOBA uses yearly MLB performance to weigh offensive measures relative to league value. This package offers the following capabilities:
the latest development version from github with
R
if (packageVersion("devtools") < 1.6) {
install.packages("devtools")
}
devtools::install_github("mdlee12/sabr")
wOBA is one of the best catch-all offensive performance statistics, but it's formula is a bit convoluted since it requires 1) ten distinct rate stats and 2) weighted values based on a season's run environment.
For example, the wOBA formula for the 2013 season was:
wOBA = (0.690×uBB + 0.722×HBP + 0.888×1B + 1.271×2B + 1.616×3B + 2.101×HR) / (AB + BB – IBB + SF + HBP)
Check out Fangraphs' library for additional details.
library(sabr) wRAA_season("braunry02","2015")
wRC_season("molitpa01","1991")
wRCp_season("yountro01","1989")
Full calculation details are in the wOBA and wRC+ calculation.Rmd file
wRCp_season makes a couple assumptions: 1. Park Factors are pulled from the Lahman Database - these are different from other sources 2. A player's primary position is used to remove pitchers from the League Runs/Plate Appearance calculation
battingseason("parrage01","2014")
battingcareer("fieldpr01")
woba_season("fieldpr01","2014")
lahman_search(nameFirst = "Robin") lahman_search(nameLast = "Fielder") lahman_search(nameGiven = "Russell Oles") lahman_search(retroID = "molip001") lahman_search(bbrefID = "yostne01")
Have a question, issue or suggestion? Create a pull request, file an issue, or feel free to contact me on Twitter or my website!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.