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_nametypes
bbref_idcharacter
seasoninteger
Namecharacter
Agenumeric
Levelcharacter
Teamcharacter
Gnumeric
PAnumeric
ABnumeric
Rnumeric
Hnumeric
X1Bnumeric
X2Bnumeric
X3Bnumeric
HRnumeric
RBInumeric
BBnumeric
IBBnumeric
uBBnumeric
SOnumeric
HBPnumeric
SHnumeric
SFnumeric
GDPnumeric
SBnumeric
CSnumeric
BAnumeric
OBPnumeric
SLGnumeric
OPSnumeric
wOBAnumeric
wOBA_CONnumeric

Examples

# \donttest{
  df <- bref_daily_batter("2015-08-01", "2015-10-03") 
  try(woba_plus(df))
#> ── MLB Daily Batter data from baseball-reference.com ───────────────────
#>  Data updated: 2022-04-30 07:17:43 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 400284     2015 Bran…    26 Maj-… New …     1     1     1     0     1
#>  2 472528     2015 Pedr…    21 Maj-… Wash…     1     1     1     1     1
#>  3 572182     2015 Jett…    25 Maj-… Los …     2     2     2     1     1
#>  4 452234     2015 Dani…    22 Maj-… Detr…     1     3     2     1     1
#>  5 502143     2015 Keit…    26 Maj-… Ariz…     1     1     1     0     1
#>  6 475100     2015 Rico…    26 Maj-… New …    13     1     1     5     1
#>  7 573627     2015 Carl…    32 Maj-… New …     1     1     1     1     1
#>  8 475582     2015 Jaso…    22 Maj-… Balt…     1     1     0     0     0
#>  9 596119     2015 Yova…    29 Maj-… Texas     1     2     2     0     1
#> 10 570256     2015 Joe …    24 Maj-… San …     4    14    12     5     5
#> # … with 754 more rows, and 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>
# }