The bbd
(BaseBall Data) package is a lightweight
package that contains functions to
facilitate the collection of baseball data from various sources online.
This package is currently experimental. All function interfaces are
liable to change without notice. For a mature and feature rich baseball
data package, consider
baseballr
.
Current data sources include:
More sources may be added in the future.
You can install the development version of bbd
from
GitHub with:
# install.packages("devtools")
devtools::install_github("daviddalpiaz/bbd")
The most basic and common usage of bbd
is collecting Statcast
data for all games
played between two dates, inclusive.
library(bbd)
ws_2022 = statcast(start = "2022-10-28", end = "2022-11-05")
By default, bbd
package attempts to be un-opinionated, and thus
returns a table containing the exact variables (to the extent possible)
returned by the Statcast API. The statcast()
function provides
arguments that allow for some opinionated processing. Check the
documentation for details of this processing. Most importantly,
functionality to obtain both batter and pitcher names is included.
This functionality is also provided by default through the use of the
opinionated statcast_bbd()
function for convenience.