obp: On-Base Percentage

Description Usage Arguments Value Author(s) References See Also Examples

Description

The OBP function calculates how often a player gets on base.

Usage

1
obp(H, BB, HBP, AB, SF)

Arguments

H

Number of Hits

BB

Number of bases on balls (walks)

HBP

Number of hit by pitches

AB

Number of at bats

SF

Number of sacrifice flies

Value

Returns a numerical value equal to ((H+BB+HBP)/(AB+BB+SF+HBP))

Author(s)

Peter Xenopoulos

References

https://en.wikipedia.org/wiki/On-base_percentage

See Also

ops

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Let's calculate Mike Trout's OBP for the 2014 season
## He had 173 hits, 83 bases on balls, 10 hit by pitches, 602 at bats, and 10 sacrifice flies
## We should get 0.377 as our output
obp(173,83,10,602,10)

## The function is currently defined as
function (H, BB, HBP, AB, SF) 
{
    onbase <- ((H + BB + HBP)/(AB + BB + SF + HBP))
    return(onbase)
  }

Sabermetrics documentation built on Jan. 15, 2017, 7:34 p.m.