Description Usage Arguments Value Author(s) References See Also Examples

The OBP function calculates how often a player gets on base.

1 | ```
obp(H, BB, HBP, AB, SF)
``` |

`H` |
Number of Hits |

`BB` |
Number of bases on balls (walks) |

`HBP` |
Number of hit by pitches |

`AB` |
Number of at bats |

`SF` |
Number of sacrifice flies |

Returns a numerical value equal to ((H+BB+HBP)/(AB+BB+SF+HBP))

Peter Xenopoulos

https://en.wikipedia.org/wiki/On-base_percentage

ops

1 2 3 4 5 6 7 8 9 10 11 | ```
## Let's calculate Mike Trout's OBP for the 2014 season
## He had 173 hits, 83 bases on balls, 10 hit by pitches, 602 at bats, and 10 sacrifice flies
## We should get 0.377 as our output
obp(173,83,10,602,10)
## The function is currently defined as
function (H, BB, HBP, AB, SF)
{
onbase <- ((H + BB + HBP)/(AB + BB + SF + HBP))
return(onbase)
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.