woba_plus: *Calculate wOBA and related metrics for any set of data*

View source: R/metrics_woba_plus.R

woba_plusR Documentation

Calculate wOBA and related metrics for any set of data

Description

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_name types description
bbref_id character Baseball-Reference player id
season integer Season (4-digit year)
Name character Player name
Age numeric Player age
Level character Level of play (e.g. MLB or minor-league level)
Team character Team name
G numeric Games played
PA numeric Plate appearances
AB numeric At-bats
R numeric Runs scored
H numeric Hits
X1B numeric Singles
X2B numeric Doubles
X3B numeric Triples
HR numeric Home runs
RBI numeric Runs batted in
BB numeric Walks (bases on balls)
IBB numeric Intentional walks
uBB numeric Unintentional walks (BB minus IBB)
SO numeric Strikeouts
HBP numeric Hit by pitch
SH numeric Sacrifice hits (bunts)
SF numeric Sacrifice flies
GDP numeric Grounded into double plays
SB numeric Stolen bases
CS numeric Caught stealing
BA numeric Batting average
OBP numeric On-base percentage
SLG numeric Slugging percentage
OPS numeric On-base plus slugging
wOBA numeric Weighted on-base average (per plate appearance)
wOBA_CON numeric Weighted on-base average per instance of fair contact

Examples


 try({
   df <- bref_daily_batter("2015-08-01", "2015-10-03") 
   woba_plus(df)
 })


baseballr documentation built on Aug. 27, 2026, 1:07 a.m.