Type: | Package |
Title: | Major League Baseball Player Statistics Calculator |
Version: | 0.1.0 |
Author: | Philip D. Waggoner <philip.waggoner@gmail.com> |
Maintainer: | Philip D. Waggoner <philip.waggoner@gmail.com> |
Description: | Computational functions for player metrics in major league baseball including batting, pitching, fielding, base-running, and overall player statistics. This package is actively maintained with new metrics being added as they are developed. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2018-03-15 17:34:46 UTC; bpwaggo |
Repository: | CRAN |
Date/Publication: | 2018-03-16 09:15:57 UTC |
Calculates the base runs estimator
Description
Takes the number of hits, bases on balls, home runs, total bases, and at bats to compute the base runs estimator, which is similar to runs created
Usage
BsR(h, bb, hr, tb, ab)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
hr |
Number of home runs |
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
ab |
Number of at bats |
Value
BsR
Examples
BsR(135, 22, 12, 155, 330)
Calculates equivalent average
Description
Takes the number of hits, total bases, bases on balls, hits by pitch, stolen bases, sacrifice hits, sacrifice flies, at bats, and caught stealing to compute the base runs, which is a player's batting average absent park and league effects
Usage
EqA(h, tb, bb, hbp, sb, sh, sf, ab, cs)
Arguments
h |
Number of hits |
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
bb |
Number of bases on balls |
hbp |
Number of hits by pitch |
sb |
Number of stolen bases |
sh |
Number of sacrifice hits (typically bunts) |
sf |
Number of sacrifice flies |
ab |
Number of at bats |
cs |
Number of caught stealing |
Value
EqA
Examples
EqA(135, 155, 22, 3, 15, 4, 2, 365, 1)
Calculates at bats per home run
Description
Takes number of at bats and divides by number of home runs
Usage
ab_hr(ab, hr)
Arguments
ab |
Number of at bats |
hr |
Number of home runs |
Value
ab_hr
Examples
ab_hr(400, 25)
Calculates adjusted earned run average (ERA+)
Description
Computes adjusted earned run average accounting for park factor and league era (compare with "era" which is the traditional formula for earned run average, "erc" which is the component earned run average, or "dice" which is the defense-independent component earned run average)
Usage
aera(er, ip, lera, home_rs, home_ra, home_r, road_rs, road_ra, road_r)
Arguments
er |
Number of runs that did not occur as a result of errors or passed balls |
ip |
Number of innings pitched |
lera |
Average league ERA |
home_rs |
Number of pitcher's team runs scored at home park |
home_ra |
Number of pitcher's team runs allowed at home park |
home_r |
Total number of runs scored at home park |
road_rs |
Number of pitcher's team runs scored at away park |
road_ra |
Number of pitcher's team runs allowed at away park |
road_r |
Total number of runs scored at away park |
Value
aera
Examples
aera(10, 5.5, 2.5, 8, 7, 15, 6, 4, 10) # for a pair of games (one away, one home)
Calculates batting average
Description
Takes number of hits and divides by at bats. 1.000 (read “one-thousand" is perfect)
Usage
ba(h, ab)
Arguments
h |
Number of hits |
ab |
Number of at bats |
Value
ba
Examples
ba(200, 525)
Calculates batting average against
Description
Computes pitcher's ability to prevent hits, based on h, bfp, bb, hbp, sf, sh, and ci (catcher's interference)
Usage
baa(h, bfp, bb, hbp, sh, sf, ci)
Arguments
h |
Number of hits allowed |
bfp |
Number of batters facing pitcher |
bb |
Number of bases on balls |
hbp |
Number of hit batters |
sh |
Number of sacrifice hits |
sf |
Number of sacrifice flies |
ci |
Number of catcher's interference |
Value
baa
Examples
baa(105, 250, 50, 15, 10, 5, 1)
Calculates batting average on balls in play
Description
Generates the frequency a batter reaches a base after putting the ball in play (normal around .300)
Usage
babip(h, hr, ab, k, sf)
Arguments
h |
Number of hits |
hr |
Number of home runs |
ab |
Number of at bats |
k |
Number of strikeouts |
sf |
Number of sacrifice flies |
Value
babip
Examples
babip(200, 25, 525, 55, 6)
Calculates bases on balls per nine innings pitched (W/9)
Description
Computes bases on balls (walks) per nine innings pitched
Usage
bb9(bb, ip)
Arguments
bb |
Number of bases on balls |
ip |
Number of innings pitched |
Value
bb9
Examples
bb9(35, 210)
Calculates walk to strikeout ratio (batting)
Description
Takes the number of bases on balls and divides by number of strikeouts (for pitching version, see "k_bb")
Usage
bb_k(bb, k)
Arguments
bb |
Number of bases on balls |
k |
Number of strikeouts |
Value
bb_k
Examples
bb_k(65, 125)
Calculates defense-independent component earned run average
Description
Computes earned run average from hits and walks (compare with "era" which is the traditional formula for earned run average, "aera" which is a pitcher's adjusted earned run average, or "erc" which is the component earned run average)
Usage
dice(bb, hbp, hr, k, ip)
Arguments
bb |
Number of bases on balls |
hbp |
Number of hit batters |
hr |
Number of home runs |
k |
Number of strikeouts |
ip |
Number of innings pitched |
Value
dice
Examples
dice(45, 10, 60, 130, 400)
Calculates earned run average
Description
Computes a pitcher's earned run average (compare with "erc" which is the component earned run average, "aera" which is a pitcher's adjusted earned run average, or "dice" which is the defense-independent component earned run average)
Usage
era(er, ip)
Arguments
er |
Number of runs that did not occur as a result of errors or passed balls |
ip |
Number of innings pitched |
Value
era
Examples
era(150, 400)
Calculates component earned run average
Description
Computes earned run average from hits and walks (compare with "era" which is the traditional formula for earned run average, "aera" which is a pitcher's adjusted earned run average, or "dice" which is the defense-independent component earned run average)
Usage
erc(h, bb, hbp, hr, ibb, bfp, ip)
Arguments
h |
Number of hits allowed |
bb |
Number of bases on balls |
hbp |
Number of hit batters |
hr |
Number of home runs |
ibb |
Number of intentional bases on balls |
bfp |
Number of batters faced by pitcher |
ip |
Number of innings pitched |
Value
erc
Examples
erc(110, 45, 10, 70, 5, 400, 215)
Calculates fielding independent pitching
Description
Computes pitching performance statistic similar to ERA, but based on factors within the pitcher's control (compare with "dice" which is the defense-independent component earned run average)
Usage
fip(hr, bb, k, ip)
Arguments
hr |
Number of home runs |
bb |
Number of bases on balls |
k |
Number of strikeouts |
ip |
Number of innings pitched |
Value
fip
Examples
fip(65, 50, 100, 175)
Calculates fielding percentage
Description
Computes the fielding percentage (aka, fielding average), which reflects the percentage of proper ball handling
Usage
fp(p, a, e)
Arguments
p |
Number of putouts |
a |
Number of assists |
e |
Number of errors |
Value
fp
Examples
fp(13, 4, 2)
Calculates ground outs-fly outs ratio (GO/AO)
Description
Takes the number of ground ball outs and divides by number of fly ball outs to compute the GO/AO ratio
Usage
go_ao(go, ao)
Arguments
go |
Number of ground ball outs |
ao |
Number of fly ball outs |
Value
go_ao
Examples
go_ao(150, 88)
Calculates gross production average
Description
Computes the gross production average, which is 1.8 times on-base percentage (OBP) plus slugging percentage (SLG), divided by four
Usage
gpa(h, bb, hbp, ab, sf, b1, b2, b3, hr)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
hbp |
Number of hits by pitch |
ab |
Number of at bats |
sf |
Number of sacrifice flies |
b1 |
Number of singles |
b2 |
Number of doubles |
b3 |
Number of triples |
hr |
Number of home runs |
Value
gpa
Examples
gpa(150, 40, 2, 400, 5, 100, 40, 3, 7)
Calculates hits per nine innings pitched (H/9IP)
Description
Computes hits per nine innings pitched
Usage
h9(h, ip)
Arguments
h |
Number of hits allowed |
ip |
Number of innings pitched |
Value
h9
Examples
h9(150, 175)
Calculates isolated power
Description
Computes isolated power, which is a player's ability to obtain extra bases from a hit. The statistic subtracts a hitter's batting average from the slugging percentage, with the maximum ISO being 3.000.
Usage
iso(b1, b2, b3, hr, ab, h)
Arguments
b1 |
Number of singles |
b2 |
Number of doubles |
b3 |
Number of triples |
hr |
Number of home runs |
ab |
Number of at bats |
h |
Number of hits |
Value
iso
Examples
iso(100, 40, 3, 7, 350, 150)
Calculates strikeouts per nine innings pitched (K/9)
Description
Computes strikeouts per nine innings pitched
Usage
k9(k, ip)
Arguments
k |
Number of strikeouts |
ip |
Number of innings pitched |
Value
k9
Examples
k9(105, 175)
Calculates strikeout to walk ratio (pitching)
Description
Computes strikeouts to walk ratio, based on number of strikeouts and number of walks (for batting version, see "bb_k")
Usage
k_bb(k, bb)
Arguments
k |
Number of strikeouts |
bb |
Number of bases on balls |
Value
k_bb
Examples
k_bb(105, 40)
Calculates on-base percentage
Description
Computes the on-base percentage based on number of hits, bases on balls, hits by pitch, at bats, and sacrifice flies
Usage
obp(h, bb, hbp, ab, sf)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
hbp |
Number of hits by pitch |
ab |
Number of at bats |
sf |
Number of sacrifice flies |
Value
obp
Examples
obp(150, 40, 2, 400, 5)
Calculates on-base plus slugging
Description
Computes the on-base percentage plus slugging average (OPS) based on number of hits, bases on balls, hits by pitch, at bats, sacrifice flies, and total weighted bases (represented individually, as in SLG and GPA calculations)
Usage
ops(h, bb, hbp, ab, sf, b1, b2, b3, hr)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
hbp |
Number of hits by pitch |
ab |
Number of at bats |
sf |
Number of sacrifice flies |
b1 |
Number of singles |
b2 |
Number of doubles |
b3 |
Number of triples |
hr |
Number of home runs |
Value
ops
Examples
ops(200, 18, 4, 401, 4, 50, 20, 3, 13)
Calculates plate appearances per strikeout (PA/SO)
Description
Computes the number of times a hitter strikes out in relation to their plate appearances
Usage
pa_so(pa, so)
Arguments
pa |
Number of plate appearances |
so |
Number of strikeouts |
Value
pa_so
Examples
pa_so(450, 120)
Calculates park factor
Description
Computes the runs a team scores at home versus away (it is often used in other metrics, e.g., adjusted era (ERA+) for pitchers; see "aera")
Usage
pafa(home_rs, home_ra, home_r, road_rs, road_ra, road_r)
Arguments
home_rs |
Number of pitcher's team runs scored at home park |
home_ra |
Number of pitcher's team runs allowed at home park |
home_r |
Total number of runs scored at home park |
road_rs |
Number of pitcher's team runs scored at away park |
road_ra |
Number of pitcher's team runs allowed at away park |
road_r |
Total number of runs scored at away park |
Value
pafa
Examples
pafa(5, 6, 11, 4, 8, 12) # for a pair of games (one home, one away)
Calculates power finesse ratio
Description
Computes pitcher's performance either by game or overall, based on k, bb, and ip
Usage
pfr(k, bb, ip)
Arguments
k |
Number of strikeouts |
bb |
Number of bases on balls |
ip |
Number of innings pitched |
Value
pfr
Examples
pfr(115, 30, 400)
Calculates run average
Description
Computes pitcher's run average based on number of runs allowed and innings pitched
Usage
ra(r, ip)
Arguments
r |
Number of runs allowed |
ip |
Number of innings pitched |
Value
ra
Examples
ra(75, 400)
Calculates runs created
Description
Computes the basic version of the estimated runs a hitter creates or contributes (see also "rc2" for the 'stolen base' iteration and "rc3" for the technical iteration of the rc statistic)
Usage
rc(h, bb, tb, ab)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
ab |
Number of at bats |
Value
rc
Examples
rc(150, 35, 165, 400)
Calculates runs created accounting for stolen bases
Description
Computes the estimated runs a hitter creates or contributes, accounting for base stealing (see also "rc" for the basic iteration and "rc3" for the technical iteration of the rc statistic)
Usage
rc2(h, bb, tb, ab, cs, sb)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
ab |
Number of at bats |
cs |
Number of stolen bases caught |
sb |
Number of stolen bases |
Value
rc2
Examples
rc2(150, 35, 165, 400, 7, 9)
Calculates runs created accounting for all offensive indicators
Description
Computes the technical iteration of estimated runs a hitter creates or contributes accounting for virtually all offensive indicators (see also "rc" for the basic iteration and "rc2" for the 'stolen base' iteration of the rc statistic)
Usage
rc3(h, bb, ibb, tb, ab, cs, sb, hbp, gidp, sh, sf)
Arguments
h |
Number of hits |
bb |
Number of bases on balls |
ibb |
Number of intentional bases on balls |
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
ab |
Number of at bats |
cs |
Number of stolen bases caught |
sb |
Number of stolen bases |
hbp |
Number of hits by pitch |
gidp |
Number of grounded into double play |
sh |
Number of sacrifice hits |
sf |
Number of sacrifice flies |
Value
rc3
Examples
rc3(150, 35, 3, 165, 400, 7, 9, 5, 1, 6, 2)
Calculates range factor
Description
Computes the amount of the field covered by a player
Usage
rfa(p, a, ip)
Arguments
p |
Number of putouts |
a |
Number of assists |
ip |
Number of innings played in a defensive position |
Value
rfa
Examples
rfa(20, 5, 450)
Calculates batting average with runners in scoring position
Description
Computes batting average accounting for runners in scoring position
Usage
risp(hrisp, abrisp)
Arguments
hrisp |
Number of hits with runners in scoring position (on either 2nd or 3rd base) |
abrisp |
Number of at bats with runners in scoring position (on either 2nd or 3rd base) |
Value
risp
Examples
risp(35, 120)
Calculates runs produced
Description
Computes the number of runs contributed by a hitter, based on runs, runs batted in, and home runs
Usage
rp(r, rbi, hr)
Arguments
r |
Number of runs |
rbi |
Number of runs batted in |
hr |
Number of home runs |
Value
rp
Examples
rp(70, 41, 22)
Calculates stolen base attempts
Description
Computes total attempts to steal a base, by adding sb and cs
Usage
sba(sb, cs)
Arguments
sb |
Number of stolen bases |
cs |
Number of caught stealing |
Value
sba
Examples
sba(20, 4)
Calculates stolen base success rate
Description
Computes percentage of bases successfully stolen
Usage
sbsr(sb, cs)
Arguments
sb |
Number of stolen bases |
cs |
Number of caught stealing |
Value
sbsr
Examples
sbsr(20, 4)
Calculates slugging percentage
Description
Computes the slugging percentage (SLG), based on the weighted number of singles, doubles, triples, home runs, and at bats
Usage
slg(b1, b2, b3, hr, ab)
Arguments
b1 |
Number of singles |
b2 |
Number of doubles |
b3 |
Number of triples |
hr |
Number of home runs |
ab |
Number of at bats |
Value
slg
Examples
slg(100, 40, 3, 7, 350)
Calculates total average
Description
Computes overall offensive contribution of a single player
Usage
ta(tb, hbp, bb, sb, ab, h, cs, gidp)
Arguments
tb |
Number of total bases (one for 1B, two for 2B, three for 3B, and four for HR) |
hbp |
Number of hits by pitch |
bb |
Number of bases on balls |
sb |
Number of stolen bases |
ab |
Number of at bats |
h |
Number of hits |
cs |
Number of caught stealing |
gidp |
Number of grounded into double play |
Value
ta
Examples
ta(125, 11, 40, 10, 400, 105, 2, 6)
Calculates total chances
Description
Computes the opportunities for defensive ball handling
Usage
tc(p, a, e)
Arguments
p |
Number of putouts |
a |
Number of assists |
e |
Number of errors |
Value
tc
Examples
tc(11, 5, 5)
Calculates times on base
Description
Computes total times a player reaches a base by adding h, hbp, and bb
Usage
tob(h, hbp, bb)
Arguments
h |
Number of hits |
hbp |
Number of hits by pitch |
bb |
Number of bases on balls |
Value
tob
Examples
tob(234, 6, 24)
Calculates value over replacement player (pitching)
Description
Computes a pitcher's marginal utility
Usage
vorp(ip, lr, lg, r)
Arguments
ip |
Number of innings pitched |
lr |
Number of league runs |
lg |
Number of league games played |
r |
Number of runs |
Value
vorp
Examples
vorp(400, 98, 20, 110)
Calculates walks plus hits per innings pitched (WHIP)
Description
Computes walks plus hits per innings pitched, which reflects the number of baserunners allowed by a pitcher over a given period
Usage
whip(bb, h, ip)
Arguments
bb |
Number of bases on balls |
h |
Number of hits allowed |
ip |
Number of innings pitched |
Value
whip
Examples
whip(50, 110, 425)
Calculates whiff rate
Description
Computes pitcher's ability to get a batter to swing and miss pitches over any period of time (e.g., in a single game, single season, career, etc.)
Usage
wr(sw, tp)
Arguments
sw |
Number of swings and misses |
tp |
Total pitches thrown |
Value
wr
Examples
wr(300, 750)
Calculates win ratio
Description
Computes a team's win ratio, which is used in the so-called "Pythagorean expectation"
Usage
wra(rs, ra)
Arguments
rs |
Number of runs scored |
ra |
Number of runs allowed |
Value
wra
Examples
wra(400, 301)
Calculates extra base hits
Description
Computes total hits by a player greater than singles (1B) by adding 2B, 3B, and hr
Usage
xbh(b2, b3, hr)
Arguments
b2 |
Number of doubles |
b3 |
Number of triples |
hr |
Number of home runs |
Value
xbh
Examples
xbh(20, 18, 4)