Learn R Programming

Sabermetrics (version 2.0)

babip: Batting Average on Balls in Play (BABIP)

Description

BABIP is a statistic which measures how often a non-home run batted ball falls for a hit.

Usage

babip(h, hr, ab, k, sf)

Arguments

h
Hits
hr
Home Runs
ab
At Bats
k
Strikeouts
sf
Sacrifice Flies

Value

Returns a numerical value equal to (h-hr)/(ab-hr-k-sf)

References

http://www.fangraphs.com/library/pitching/babip/

See Also

obp,ops

Examples

Run this code
## Let's Calculate Mike Trout's BABIP for the 2014 season
## He had 173 Hits, 36 HR's, 602 AB's, 184 K's, and 10 SF's
## We should get .368 as our output
babip(173,36,602,184,10)

## The function is currently defined as
function (h, hr, ab, k, sf) 
{
    babip <- (h-hr)/(ab-hr-k-sf)
    return(babip)
  }

Run the code above in your browser using DataLab