## Let's Calculate Mike Trout's BABIP for the 2014 season
## He had 173 Hits, 36 HR's, 602 AB's, 184 K's, and 10 SF's
## We should get .368 as our output
babip(173,36,602,184,10)
## The function is currently defined as
function (h, hr, ab, k, sf)
{
babip <- (h-hr)/(ab-hr-k-sf)
return(babip)
}
Run the code above in your browser using DataLab