## 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