Learn R Programming

Sabermetrics (version 1.0)

secA: Secondary Average

Description

Secondary average, or SecA, is a baseball statistic that measures the sum of extra bases gained on hits, walks, and stolen bases (less times caught stealing) depicted per at bat.

Usage

secA(BB, TB, H, SB, CS, AB)

Arguments

BB
Walks
TB
Total Bases
H
Hits
SB
Stolen Bases
CS
Caught Stealing
AB
At Bats

Value

  • Returns (BB+(TB-H)+(SB-CS))/AB

References

http://en.wikipedia.org/wiki/Secondary_average

Examples

Run this code
## The secondary average (secA) function is currently defined as
function (BB, TB, H, SB, CS, AB) 
{
    avg <- (BB + (TB - H) + (SB - CS))/AB
    return(avg)
  }
  
## Let's take 2014's MLB MVP, Mike Trout, and find his SecA
## Stats for Mike Trout available on
## http://www.baseball-reference.com/players/t/troutmi01-bat.shtml
## For 2014, Trout had 83 BB, 338 TB, 173 H, 16 SB, 2 CS, 602 AB
## The formula for his SecA using the ops function is below
## Output should be .4352159
secA(83,338,173,16,2,602)

Run the code above in your browser using DataLab