Learn R Programming

baseballr (version 0.7.0)

scrape_savant_leaderboards: Query BaseballSavant Leaderboards from http://baseballsavant.mlb.com

Description

This function allows you to read leaderboard data from BaseballSavant dirctly into R as #` a data.frame.

Usage

scrape_savant_leaderboards(
  leaderboard = "exit_velocity_barrels",
  year = 2018,
  abs = 50,
  min_pa = 250,
  min_pitches = 100,
  min_field = "q",
  min_run = 0,
  player_type = "batter",
  fielding_type = "player",
  team = "",
  arsenal_type = "n_",
  run_type = "raw",
  min2b = 5,
  min3b = 0,
  position = "",
  bats = "",
  hand = ""
)

Arguments

leaderboard

The type of leaderboard to retrieve, input as a string. Current options include exit_velocity_barrels, expected_statistics, pitch_arsenal, outs_above_average, directional_oaa, catch_probability, pop_time, sprint_speed, and running_splits_90_ft.

year

The season for which you want data.

abs

The minimum number of batted balls. Applies only to exit_velocity_barrels leaderboards.

min_pa

Minimum number of plate appearances.

min_pitches

Minimum number of pitches thrown.

min_field

Minimum number of fieding opportunities.

min_run

Minimum number of running opportunities.

player_type

One of either 'batter' or pitcher. For the expected_statistics leaderboard, 'batter-team' and 'pitcher-team' are also available.

fielding_type

One of either 'player' or 'team'.

team

An abbreviation for a team. Can be left blank.

arsenal_type

One of either 'n_', 'avg_spin', or 'avg_speed'.

run_type

One of either 'percent' or 'raw'.

min2b

The minimum number of throwing attempts to second base.

min3b

The minimum number of throwing attempts to third base.

position

The numeric position of the player. For DH use 10. Can be left blank.

bats

The handedness of the batter. One of 'R' or 'L'. Can be left blank.

hand

The handedness of the pitcher. One of 'R' or 'L'. Can be left blank.

Examples

Run this code
# NOT RUN {
correa <- scrape_statcast_savant(start_date = "2016-04-06",
  end_date = "2016-04-15", playerid = 621043)

noah <- scrape_statcast_savant(start_date = "2016-04-06",
  end_date = "2016-04-15", playerid = 592789, player_type = 'pitcher')

daily <- scrape_statcast_savant(start_date = "2016-04-06", end_date = "2016-04-06")
# }

Run the code above in your browser using DataLab