## Field Independent Pitching (fip) function is currently defined as
function (HR, BB, K, IP, C)
{
fieldIndPitch <- ((13 * HR + 3 * BB - 2 * K)/IP) + C
return(fieldIndPitch)
}
## Let's take 2014's MLB MVP, Clayton Kershaw, and find his FIPS
## Stats for Clayton Kershaw available on
## http://www.baseball-reference.com/players/k/kershcl01-pitch.shtml
## For 2014, Kershaw allowed 9 HR, 31 BB, 239 K, 198.1 IP and league era (C) of 3.66
## The formula for his FIPS using the dice function is below
## Output should be 2.307148
fip(9,31,239,198.1,3.66)
Run the code above in your browser using DataLab