## Let's calculate Clayton Kershaw's 2014 FIP
## He had 9 HR's, 31 BB's, 2 HBP's, 239 K's, and 198.333 IP's
## We should get 1.81 as our output
fip(9,31,2,239,198.333,2014)
## The function is currently defined as
function (HR, BB, HBP, K, IP, year)
{
constant <- weights$cFIP[which(weights$Season == year)]
fip <- ((13 * HR) + (3 * (BB + HBP)) - (2 * K))/IP + constant
return(fip)
}
Run the code above in your browser using DataLab