This function allows you to query Statcast data as provided on https://baseballsavant.mlb.com
Usage
statcast_search(
start_date = Sys.Date() - 1,
end_date = Sys.Date(),
playerid = NULL,
player_type = "batter",
...
)
statcast_search.default(
start_date = Sys.Date() - 1,
end_date = Sys.Date(),
playerid = NULL,
player_type = "batter",
...
)
statcast_search_batters(start_date, end_date, batterid = NULL, ...)
statcast_search_pitchers(start_date, end_date, pitcherid = NULL, ...)
Arguments
- start_date
Date of first game for which you want data. Format must be in YYYY-MM-DD format.
- end_date
Date of last game for which you want data. Format must be in YYYY-MM-DD format.
- playerid
The MLBAM ID for the player whose data you want to query.
- player_type
The player type. Can be
batter
orpitcher
. Default isbatter
- ...
currently ignored
- batterid
The MLBAM ID for the batter whose data you want to query.
- pitcherid
The MLBAM ID for the pitcher whose data you want to query.
Value
Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Returns a tibble with Statcast data. Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Examples
# \donttest{
### Correa
x<- try(statcast_search(start_date = "2016-04-06",
end_date = "2016-04-15",
playerid = 621043,
player_type = 'batter'))
### Noah
try(statcast_search(start_date = "2016-04-06",
end_date = "2016-04-15",
playerid = 592789,
player_type = 'pitcher'))
#> ── MLB Baseball Savant Statcast Search data from baseballsavant.mlb.com
#> ℹ Data updated: 2022-04-30 07:17:24 UTC
#> # A tibble: 99 × 92
#> pitch_type game_date release_speed release_pos_x release_pos_z
#> <chr> <date> <dbl> <dbl> <dbl>
#> 1 SI 2016-04-12 97.3 -0.61 6.28
#> 2 SI 2016-04-12 97.8 -0.57 6.24
#> 3 SI 2016-04-12 97.6 -0.43 6.23
#> 4 FF 2016-04-12 97 -0.61 6.39
#> 5 SL 2016-04-12 91.6 -0.68 6.28
#> 6 CH 2016-04-12 88.9 -0.91 6.06
#> 7 CH 2016-04-12 88.1 -0.84 6.21
#> 8 SI 2016-04-12 95.7 -0.88 6.39
#> 9 SI 2016-04-12 95.7 -0.67 6.28
#> 10 CH 2016-04-12 90.8 -0.78 6.05
#> # … with 89 more rows, and 87 more variables: player_name <chr>,
#> # batter <dbl>, pitcher <dbl>, events <chr>, description <chr>,
#> # spin_dir <lgl>, spin_rate_deprecated <lgl>,
#> # break_angle_deprecated <lgl>, break_length_deprecated <lgl>,
#> # zone <dbl>, des <chr>, game_type <chr>, stand <chr>,
#> # p_throws <chr>, home_team <chr>, away_team <chr>, type <chr>,
#> # hit_location <int>, bb_type <chr>, balls <int>, strikes <int>, …
### Daily
try(statcast_search(start_date = "2016-04-06",
end_date = "2016-04-06"))
#> ── MLB Baseball Savant Statcast Search data from baseballsavant.mlb.com
#> ℹ Data updated: 2022-04-30 07:17:25 UTC
#> # A tibble: 3,846 × 92
#> pitch_type game_date release_speed release_pos_x release_pos_z
#> <chr> <date> <dbl> <dbl> <dbl>
#> 1 FF 2016-04-06 92.1 -1.24 6.35
#> 2 CU 2016-04-06 84.8 -2.2 5.8
#> 3 FF 2016-04-06 92 -1.23 6.32
#> 4 CU 2016-04-06 83.1 -2.7 6.49
#> 5 FF 2016-04-06 91.1 -1.29 6.6
#> 6 FF 2016-04-06 96.9 -1.98 5.74
#> 7 FF 2016-04-06 96.6 -1.91 5.74
#> 8 CH 2016-04-06 83.6 -1.03 6.07
#> 9 CH 2016-04-06 81.2 -2.78 6.4
#> 10 FF 2016-04-06 95 -2.07 5.87
#> # … with 3,836 more rows, and 87 more variables: player_name <chr>,
#> # batter <dbl>, pitcher <dbl>, events <chr>, description <chr>,
#> # spin_dir <lgl>, spin_rate_deprecated <lgl>,
#> # break_angle_deprecated <lgl>, break_length_deprecated <lgl>,
#> # zone <dbl>, des <chr>, game_type <chr>, stand <chr>,
#> # p_throws <chr>, home_team <chr>, away_team <chr>, type <chr>,
#> # hit_location <int>, bb_type <chr>, balls <int>, strikes <int>, …
# }
# \donttest{
correa <- statcast_search_batters(start_date = "2016-04-06",
end_date = "2016-04-15", batterid = 621043)
daily <- statcast_search_batters(start_date = "2016-04-06",
end_date = "2016-04-06", batterid = NULL)
# }
# \donttest{
x <- statcast_search_pitchers(start_date = "2016-04-06",
end_date = "2016-04-15", pitcherid = 592789)
daily <- statcast_search_pitchers(start_date = "2016-04-06",
end_date = "2016-04-06", pitcherid = NULL)
# }