Skip to contents

This function allows you to calculate wOBA for any given set of data, provided the right variables are in the data set. The function currently returns both wOBA per plate appearance on wOBA per instance of fair contact.

Usage

woba_plus(df)

Arguments

df

A data frame of statistics that includes, at a minimum, the following columns: uBB (unintentional walks), HBP (Hit By Pitch), X1B (singles), X2B (doubles), X3B (triples), HR (home runs), AB (at-bats), SH (sacrifice hits), SO (strike outs), and season.

Value

Returns a tibble with the wOBA factors calculated and the following columns:

col_nametypesdescription
bbref_idcharacterBaseball-Reference player id
seasonintegerSeason (4-digit year)
NamecharacterPlayer name
AgenumericPlayer age
LevelcharacterLevel of play (e.g. MLB or minor-league level)
TeamcharacterTeam name
GnumericGames played
PAnumericPlate appearances
ABnumericAt-bats
RnumericRuns scored
HnumericHits
X1BnumericSingles
X2BnumericDoubles
X3BnumericTriples
HRnumericHome runs
RBInumericRuns batted in
BBnumericWalks (bases on balls)
IBBnumericIntentional walks
uBBnumericUnintentional walks (BB minus IBB)
SOnumericStrikeouts
HBPnumericHit by pitch
SHnumericSacrifice hits (bunts)
SFnumericSacrifice flies
GDPnumericGrounded into double plays
SBnumericStolen bases
CSnumericCaught stealing
BAnumericBatting average
OBPnumericOn-base percentage
SLGnumericSlugging percentage
OPSnumericOn-base plus slugging
wOBAnumericWeighted on-base average (per plate appearance)
wOBA_CONnumericWeighted on-base average per instance of fair contact

Examples

# \donttest{
 try({
   df <- bref_daily_batter("2015-08-01", "2015-10-03") 
   woba_plus(df)
 })
#> ── MLB Daily Batter data from baseball-reference.com ───────────────────
#>  Data updated: 2026-06-12 14:10:08 UTC
#> # A tibble: 764 × 32
#>    bbref_id season Name    Age Level Team      G    PA    AB     R     H
#>    <chr>     <int> <chr> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1 pindebr…   2015 Bran…    26 Maj-… New …     1     1     1     0     1
#>  2 severpe…   2015 Pedr…    21 Maj-… Wash…     1     1     1     1     1
#>  3 bandyje…   2015 Jett…    25 Maj-… Los …     2     2     2     1     1
#>  4 norrida…   2015 Dani…    22 Maj-… Detr…     1     3     2     1     1
#>  5 hesslke…   2015 Keit…    26 Maj-… Ariz…     1     1     1     0     1
#>  6 noelri02   2015 Rico…    26 Maj-… New …    13     1     1     5     1
#>  7 torreca…   2015 Carl…    32 Maj-… New …     1     1     1     1     1
#>  8 garcija…   2015 Jaso…    22 Maj-… Balt…     1     1     0     0     0
#>  9 gallayo…   2015 Yova…    29 Maj-… Texas     1     2     2     0     1
#> 10 panikjo…   2015 Joe …    24 Maj-… San …     4    14    12     5     5
#> # ℹ 754 more rows
#> # ℹ 21 more variables: X1B <dbl>, X2B <dbl>, X3B <dbl>, HR <dbl>,
#> #   RBI <dbl>, BB <dbl>, IBB <dbl>, uBB <dbl>, SO <dbl>, HBP <dbl>,
#> #   SH <dbl>, SF <dbl>, GDP <dbl>, SB <dbl>, CS <dbl>, BA <dbl>,
#> #   OBP <dbl>, SLG <dbl>, OPS <dbl>, wOBA <dbl>, wOBA_CON <dbl>
# }