Learn R Programming

Sabermetrics (version 1.0)

ops: On-base plus Slugging

Description

Function to calculate on base percentage plus slugging percentage. This is a measure of a hitter's ability to hit for power and get on base.

Usage

ops(slg, obp)

Arguments

slg
Slugging percentage. Found from slg
obp
On-base percentage. Found from obp

Value

  • Returns On-Base Percentage + Slugging Percentage

References

http://en.wikipedia.org/wiki/On-base_plus_slugging

See Also

On-base Percentage obp and Slugging Percentage slg

Examples

Run this code
## The on-base percentage plus slugging (ops) function is currently defined as
function (slg, obp) 
{
    ops <- slg + obp
    return(ops)
  }
  
## Let's take 2014's MLB MVP, Mike Trout, and find his OPS
## Stats for Mike Trout available on
## http://www.baseball-reference.com/players/t/troutmi01-bat.shtml
## For 2014, Trout had a SLG of .561 and an OBP of .377
## The formula for his OPS using the ops function is below
## Output should be .938
ops(0.561,0.377)

Run the code above in your browser using DataLab