Skip to contents

Baseball Savant downloads are limited to 25,000 rows. These functions help you build a larger database easily.

Usage

statcast_daily(the_date = lubridate::now(), dir = getwd())

statcast_season(year = lubridate::year(lubridate::now()), dir = getwd())

statcast_read_csv(dir = getwd(), pattern = "*.csv")

statcast_write_rds(x, dir = getwd(), ...)

Arguments

the_date

The date on which you want to download data

dir

Path to a directory to store downloaded files

year

The year for which you want to download data

pattern

passed to base::list.files()

x

Data frame to write. See readr::write_rds().

...

arguments passed to readr::write_rds(). Currently ignored.

Value

Always NULL, as the file is written to disk.

Examples

statcast_daily("2023-06-11", dir = tempdir())
#> Retrieving data from 2023-06-11
#> Error: Can't assign 92 names to a 94-column data.table

x <- statcast_read_csv(tempdir())
x <- statcast_read_csv(tempdir())
statcast_write_rds(x, tempdir())
#> Error in dplyr::group_by(x, year = lubridate::year(game_date)):  In argument: `year = lubridate::year(game_date)`.
#> Caused by error:
#> ! object 'game_date' not found