Title: | Acquiring and Analyzing Baseball Data |
---|---|
Description: | Provides numerous utilities for acquiring and analyzing baseball data from online sources such as 'Baseball Reference' <https://www.baseball-reference.com/>, 'FanGraphs' <https://www.fangraphs.com/>, and the 'MLB Stats' API <https://www.mlb.com/>. |
Authors: | Bill Petti [aut], Saiem Gilani [aut, cre], Ben Baumer [ctb], Ben Dilday [ctb], Robert Frey [ctb], Camden Kay [ctb] |
Maintainer: | Saiem Gilani <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.6.0.9001 |
Built: | 2025-02-13 04:59:10 UTC |
Source: | https://github.com/billpetti/baseballr |
(legacy) Scrape Batter Game Logs from FanGraphs
batter_game_logs_fg(playerid, year)
batter_game_logs_fg(playerid, year)
playerid |
This is the playerid used by FanGraphs for a given player |
year |
The season for which game logs should be returned (use the YYYY format) |
A data frame of batter game logs.
bref_daily_batter()
Scrape Batter Performance Data Over a Custom Time Frame
bref_daily_pitcher()
Scrape Pitcher Performance Data Over a Custom Time Frame
bref_standings_on_date()
Scrape MLB Standings on a Given Date
bref_team_results()
Scrape Team Results
bref_daily_batter("2015-05-10", "2015-06-20")
bref_daily_batter("2015-05-10", "2015-06-20")
bref_standings_on_date(date = "2015-08-04", division = "AL East")
bref_team_results("NYM", 2015) bref_team_results(Tm="TBR", year=2008)
Uses bref_team_results()
to calculate team consistency metrics
team_consistency(year=2015)
This function allows you to scrape basic batter statistics over a custom time frame. Data is sourced from Baseball-Reference.com.
bref_daily_batter(t1, t2)
bref_daily_batter(t1, t2)
t1 |
First date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
t2 |
Last date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
Returns a tibble of batter performance with the following columns:
col_name | types |
bbref_id | character |
season | integer |
Name | character |
Age | numeric |
Level | character |
Team | character |
G | numeric |
PA | numeric |
AB | numeric |
R | numeric |
H | numeric |
X1B | numeric |
X2B | numeric |
X3B | numeric |
HR | numeric |
RBI | numeric |
BB | numeric |
IBB | numeric |
uBB | numeric |
SO | numeric |
HBP | numeric |
SH | numeric |
SF | numeric |
GDP | numeric |
SB | numeric |
CS | numeric |
BA | numeric |
OBP | numeric |
SLG | numeric |
OPS | numeric |
try(bref_daily_batter(t1="2015-05-10", t2="2015-06-20"))
try(bref_daily_batter(t1="2015-05-10", t2="2015-06-20"))
This function allows you to scrape basic pitcher statistics over a custom time frame. Data is sourced from Baseball-Reference.com.
bref_daily_pitcher(t1, t2)
bref_daily_pitcher(t1, t2)
t1 |
First date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
t2 |
Last date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
Returns a tibble of pitcher performance with the following columns:
col_name | types |
bbref_id | character |
season | integer |
Name | character |
Age | numeric |
Level | character |
Team | character |
G | numeric |
GS | numeric |
W | numeric |
L | numeric |
SV | numeric |
IP | numeric |
H | numeric |
R | numeric |
ER | numeric |
uBB | numeric |
BB | numeric |
SO | numeric |
HR | numeric |
HBP | numeric |
ERA | numeric |
AB | numeric |
X1B | numeric |
X2B | numeric |
X3B | numeric |
IBB | numeric |
GDP | numeric |
SF | numeric |
SB | numeric |
CS | numeric |
PO | numeric |
BF | numeric |
Pit | numeric |
Str | numeric |
StL | numeric |
StS | numeric |
GB.FB | numeric |
LD | numeric |
PU | numeric |
WHIP | numeric |
BAbip | numeric |
SO9 | numeric |
SO.W | numeric |
SO_perc | numeric |
uBB_perc | numeric |
SO_uBB | numeric |
try(bref_daily_pitcher("2015-05-10", "2015-06-20"))
try(bref_daily_pitcher("2015-05-10", "2015-06-20"))
This function allows you to scrape the standings from MLB for any date you choose.
bref_standings_on_date(date, division, from = FALSE)
bref_standings_on_date(date, division, from = FALSE)
date |
a date object |
division |
One or more of AL East, AL Central, AL West, AL Overall, NL East, NL Central, NL West, and NL Overall |
from |
a logical indicating whether you want standings up to and including the date (FALSE, default) or rather standings for games played after the date |
Returns a tibble of MLB standings with the following columns:
col_name | types |
Tm | character |
W | integer |
L | integer |
W-L% | numeric |
GB | character |
RS | integer |
RA | integer |
pythW-L% | numeric |
try(bref_standings_on_date(date = "2015-08-04", division = "AL East"))
try(bref_standings_on_date(date = "2015-08-04", division = "AL East"))
This function allows you to scrape schedule and results for a major league team from Baseball-Reference.com
bref_team_results(Tm, year)
bref_team_results(Tm, year)
Tm |
The abbreviation used by Baseball-Reference.com for the team whose results you want to scrape. |
year |
Season for which you want to scrape the park factors. |
Returns a tibble of MLB team results and the following columns:
col_name | types |
Gm | numeric |
Date | character |
Tm | character |
H_A | character |
Opp | character |
Result | character |
R | numeric |
RA | numeric |
Inn | character |
Record | character |
Rank | numeric |
GB | character |
Win | character |
Loss | character |
Save | character |
Time | character |
D/N | character |
Attendance | numeric |
cLI | numeric |
Streak | numeric |
Orig_Scheduled | character |
Year | numeric |
try(bref_team_results("NYM", 2015)) try(bref_team_results(Tm="TBR", year=2008))
try(bref_team_results("NYM", 2015)) try(bref_team_results(Tm="TBR", year=2008))
chadwick_player_lu()
:Directly download the Chadwick Bureau's public register of baseball players and the various IDs associated with them in different systems of record.
playername_lookup()
:Look up Baseball Player Name.
playerid_lookup()
:Look up Baseball Player IDs.
chadwick_player_lu()
playername_lookup(4885) playername_lookup("kaaihki01")
playerid_lookup("Garcia", "Karim")
Utility functions to help ensure that Chadwick is set up correctly.
The easiest way for the Chadwick CLI
tools to work on *nix systems is to
set the LD_LIBRARY_PATH
environment variable. Unfortunately this environment
variable is not set by default during the Chadwick installation.
chadwick_ld_library_path()
checks to find the Chadwick shared libraries, and then
set the LD_LIBRARY_PATH
environment variable.
If chadwick_ld_library_path()
returns TRUE
, the cwevent
command line program
that retrosheet_data
depends on should work.
The other functions documented here are mostly for internal use.
chadwick_path() chadwick_is_installed() chadwick_find_lib() chadwick_set_ld_library_path() chadwick_ld_library_path()
chadwick_path() chadwick_is_installed() chadwick_find_lib() chadwick_set_ld_library_path() chadwick_ld_library_path()
If Chadwick is not installed NULL
. If Chadwick is installed, the path to the cwevent
binary.
TRUE
or FALSE
Path to the Chadwick shared library.
chadwick_path() chadwick_is_installed() chadwick_find_lib() ## Not run: if (chadwick_ld_library_path()) { retrosheet_data(tempdir()) } ## End(Not run)
chadwick_path() chadwick_is_installed() chadwick_find_lib() ## Not run: if (chadwick_ld_library_path()) { retrosheet_data(tempdir()) } ## End(Not run)
Download the Chadwick Bureau's public register of baseball players
chadwick_player_lu() get_chadwick_lu()
chadwick_player_lu() get_chadwick_lu()
A data frame of baseball players and the various IDs associated with them in different systems of record and the following columns:
col_name | types |
key_person | character |
key_uuid | character |
key_mlbam | integer |
key_retro | character |
key_bbref | character |
key_bbref_minors | character |
key_fangraphs | integer |
key_npb | integer |
key_sr_nfl | character |
key_sr_nba | character |
key_sr_nhl | character |
key_findagrave | integer |
name_last | character |
name_first | character |
name_given | character |
name_suffix | character |
name_matrilineal | character |
name_nick | character |
birth_year | integer |
birth_month | integer |
birth_day | integer |
death_year | integer |
death_month | integer |
death_day | integer |
pro_played_first | integer |
pro_played_last | integer |
mlb_played_first | integer |
mlb_played_last | integer |
col_played_first | integer |
col_played_last | integer |
pro_managed_first | integer |
pro_managed_last | integer |
mlb_managed_first | integer |
mlb_managed_last | integer |
col_managed_first | integer |
col_managed_last | integer |
pro_umpired_first | integer |
pro_umpired_last | integer |
mlb_umpired_first | integer |
mlb_umpired_last | integer |
A data frame of baseball players and the various IDs associated with them in different systems of record.
try(chadwick_player_lu())
try(chadwick_player_lu())
This function allows you to code a batted ball as a barrel as defined by the Statcast research team using data as provided by baseballsavant.mlb.com.
code_barrel(df)
code_barrel(df)
df |
A dataframe generated by baseballsavant.mlb.com that must include the following variables: |
Returns a tibble with the additional column, barrel
.
A tibble giving column structure of MLB Draft data
column_structure_draft_mlb
column_structure_draft_mlb
An object of class tbl_df
(inherits from tbl
, data.frame
) with 0 rows and 72 columns.
(legacy) Scrape Batter Performance Data Over a Custom Time Frame
daily_batter_bref(t1, t2)
daily_batter_bref(t1, t2)
t1 |
First date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
t2 |
Last date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
Returns a tibble of batter performance
bref_daily_batter()
(legacy) Scrape Pitcher Performance Data Over a Custom Time Frame
daily_pitcher_bref(t1, t2)
daily_pitcher_bref(t1, t2)
t1 |
First date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
t2 |
Last date data should be scraped from. Should take the form "YEAR-MONTH-DAY" |
Returns a tibble of pitcher performance
bref_daily_pitcher()
This function allows you to classify individual pitches based on the various categories from the Edge% metric. The dataframe passed to the function must include the batter's handedness, the px and pz coordinates from the PITCHf/x system, and the batter's height.
edge_code(df, height_var_name = "b_height")
edge_code(df, height_var_name = "b_height")
df |
A dataframe that, at a minimum, includes the following columns: batter height (b_height), the batter's handedness (stand), vertical location of the pitch (pz), and then horizontal location of the pitch (pz) |
height_var_name |
The name of the variable in the data set that includes the batter's height. Defaults to b_height which assumes an height + inch format. If the variable name is "Height" it assumes the variable is already converted to inches (as is the case in some databases) |
Returns a tibble with the additional edge columns necessary for calculations.
This function allows you to calculate the percent of pitches thrown to different edges of the strike zone for a pitch by pitch data set that has been coded using the edge_code()
function.
edge_frequency(df, group = NULL)
edge_frequency(df, group = NULL)
df |
A data frame of pitch by pitch data that has been coded using the |
group |
Character string indicating what column to group the frequency by. For example, "pitcher" or "batter". Defaults to NULL, which calculates the frequencies across the entire data set. |
Returns a tibble with the additional edge columns necessary for frequency calculations.
fg_pitcher_game_logs()
:Scrape Pitcher Game Logs from FanGraphs.
fg_batter_game_logs()
:Scrape Batter Game Logs from FanGraphs.
fg_milb_pitcher_game_logs()
:Scrape MiLB game logs for pitchers from Fangraphs, combining 'standard' and 'advanced' tabs.
fg_milb_batter_game_logs()
:Scrape MiLB game logs for batters from Fangraphs, combining 'standard' and 'advanced' tabs.
fg_batter_leaders()
:Scrape Batter Leaderboards from FanGraphs.
fg_pitcher_leaders()
:Scrape Pitcher Leaderboards from FanGraphs.
fg_fielder_leaders()
:Scrape Fielder Leaderboards from FanGraphs.
fg_team_batter()
:Scrape Team Batter Leaderboards from FanGraphs.
fg_team_pitcher()
:Scrape Team Pitcher Leaderboards from FanGraphs.
fg_team_fielder()
:Scrape Team Fielder Leaderboards from FanGraphs.
fg_guts()
:Scrape FanGraphs.com Guts!.
fg_park()
:Scrape Park Factors from FanGraphs.com.
fg_park_hand()
:Scrape Park Factors by handedness from FanGraphs.com.
fg_pitcher_game_logs(playerid = 104, year = 2006)
fg_batter_game_logs(playerid = 6184, year = 2017)
fg_milb_pitcher_game_logs(playerid = "sa3004210", year=2017)
fg_milb_batter_game_logs(playerid = "sa917940", year=2018)
fg_batter_leaders(startseason = 2015, endseason = 2015, qual = 400)
fg_pitcher_leaders(startseason = 2015, endseason = 2015, qual = 150)
fg_fielder_leaders(startseason = 2015, endseason = 2015, qual = 150)
fg_team_batter(startseason = 2015, endseason = 2015, qual = 400)
fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150)
fg_team_fielder(startseason = 2015, endseason = 2015, qual = 150)
fg_guts()
fg_park(2013)
fg_park_hand(2013)
(legacy) Scrape Batter Leaderboards from FanGraphs
(legacy) Scrape Batter Leaderboards from FanGraphs
fg_bat_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" ) fg_bat_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_bat_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" ) fg_bat_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of batter data.
A data frame of batter data.
This function allows you to scrape game logs by year for a batter from FanGraphs.com.
fg_batter_game_logs(playerid, year)
fg_batter_game_logs(playerid, year)
playerid |
This is the playerid used by FanGraphs for a given player |
year |
The season for which game logs should be returned (use the YYYY format) |
A data frame of batter game logs. |col_name |types | |:————-|:———| |PlayerName |character | |playerid |integer | |Date |character | |Team |character | |Opp |character | |season |integer | |Age |integer | |BatOrder |character | |Pos |character | |G |numeric | |AB |numeric | |PA |numeric | |H |numeric | |1B |numeric | |2B |numeric | |3B |numeric | |HR |numeric | |R |numeric | |RBI |numeric | |BB |numeric | |IBB |numeric | |SO |numeric | |HBP |numeric | |SF |numeric | |SH |numeric | |GDP |numeric | |SB |numeric | |CS |numeric | |AVG |numeric | |GB |numeric | |FB |numeric | |LD |numeric | |IFFB |numeric | |Pitches |numeric | |Balls |numeric | |Strikes |numeric | |IFH |numeric | |BU |numeric | |BUH |numeric | |BB% |numeric | |K% |numeric | |BB/K |numeric | |OBP |numeric | |SLG |numeric | |OPS |numeric | |ISO |numeric | |BABIP |numeric | |GB/FB |numeric | |LD% |numeric | |GB% |numeric | |FB% |numeric | |IFFB% |numeric | |HR/FB |numeric | |IFH% |numeric | |BUH% |numeric | |wOBA |numeric | |wRAA |numeric | |wRC |numeric | |Spd |numeric | |wRC+ |numeric | |wBSR |numeric | |WPA |numeric | |-WPA |numeric | |+WPA |numeric | |RE24 |numeric | |REW |numeric | |pLI |numeric | |phLI |numeric | |PH |numeric | |WPA/LI |numeric | |Clutch |numeric | |FB%1 |numeric | |FBv |numeric | |SL% |numeric | |SLv |numeric | |CT% |numeric | |CTv |numeric | |CB% |numeric | |CBv |numeric | |CH% |numeric | |CHv |numeric | |SF% |numeric | |SFv |numeric | |KN% |numeric | |KNv |numeric | |XX% |numeric | |wFB |numeric | |wSL |numeric | |wCT |numeric | |wCB |numeric | |wCH |numeric | |wSF |numeric | |wKN |numeric | |wFB/C |numeric | |wSL/C |numeric | |wCT/C |numeric | |wCB/C |numeric | |wCH/C |numeric | |wSF/C |numeric | |wKN/C |numeric | |O-Swing% |numeric | |Z-Swing% |numeric | |Swing% |numeric | |O-Contact% |numeric | |Z-Contact% |numeric | |Contact% |numeric | |Zone% |numeric | |F-Strike% |numeric | |SwStr% |numeric | |Pull |numeric | |Cent |numeric | |Oppo |numeric | |Soft |numeric | |Med |numeric | |Hard |numeric | |bipCount |numeric | |Pull% |numeric | |Cent% |numeric | |Oppo% |numeric | |Soft% |numeric | |Med% |numeric | |Hard% |numeric | |pfxFA% |numeric | |pfxFT% |numeric | |pfxFC% |numeric | |pfxFS% |numeric | |pfxFO% |numeric | |pfxSI% |numeric | |pfxSL% |numeric | |pfxCU% |numeric | |pfxKC% |numeric | |pfxCH% |numeric | |pfxKN% |numeric | |pfxvFA |numeric | |pfxvFT |numeric | |pfxvFC |numeric | |pfxvFS |numeric | |pfxvFO |numeric | |pfxvSI |numeric | |pfxvSL |numeric | |pfxvCU |numeric | |pfxvKC |numeric | |pfxvCH |numeric | |pfxvKN |numeric | |pfxFA-X |numeric | |pfxFT-X |numeric | |pfxFC-X |numeric | |pfxFS-X |numeric | |pfxFO-X |numeric | |pfxSI-X |numeric | |pfxSL-X |numeric | |pfxCU-X |numeric | |pfxKC-X |numeric | |pfxCH-X |numeric | |pfxKN-X |numeric | |pfxFA-Z |numeric | |pfxFT-Z |numeric | |pfxFC-Z |numeric | |pfxFS-Z |numeric | |pfxFO-Z |numeric | |pfxSI-Z |numeric | |pfxSL-Z |numeric | |pfxCU-Z |numeric | |pfxKC-Z |numeric | |pfxCH-Z |numeric | |pfxKN-Z |numeric | |pfxwFA |numeric | |pfxwFT |numeric | |pfxwFC |numeric | |pfxwFS |numeric | |pfxwFO |numeric | |pfxwSI |numeric | |pfxwSL |numeric | |pfxwCU |numeric | |pfxwKC |numeric | |pfxwCH |numeric | |pfxwKN |numeric | |pfxwFA/C |numeric | |pfxwFT/C |numeric | |pfxwFC/C |numeric | |pfxwFS/C |numeric | |pfxwFO/C |numeric | |pfxwSI/C |numeric | |pfxwSL/C |numeric | |pfxwCU/C |numeric | |pfxwKC/C |numeric | |pfxwCH/C |numeric | |pfxwKN/C |numeric | |pfxO-Swing% |numeric | |pfxZ-Swing% |numeric | |pfxSwing% |numeric | |pfxO-Contact% |numeric | |pfxZ-Contact% |numeric | |pfxContact% |numeric | |pfxZone% |numeric | |pfxPace |numeric | |piCH% |numeric | |piCS% |numeric | |piCU% |numeric | |piFA% |numeric | |piFC% |numeric | |piFS% |numeric | |piKN% |numeric | |piSI% |numeric | |piSL% |numeric | |piXX% |numeric | |pivCH |numeric | |pivCS |numeric | |pivCU |numeric | |pivFA |numeric | |pivFC |numeric | |pivFS |numeric | |pivKN |numeric | |pivSI |numeric | |pivSL |numeric | |pivXX |numeric | |piCH-X |numeric | |piCS-X |numeric | |piCU-X |numeric | |piFA-X |numeric | |piFC-X |numeric | |piFS-X |numeric | |piKN-X |numeric | |piSI-X |numeric | |piSL-X |numeric | |piXX-X |numeric | |piCH-Z |numeric | |piCS-Z |numeric | |piCU-Z |numeric | |piFA-Z |numeric | |piFC-Z |numeric | |piFS-Z |numeric | |piKN-Z |numeric | |piSI-Z |numeric | |piSL-Z |numeric | |piXX-Z |numeric | |piwCH |numeric | |piwCS |numeric | |piwCU |numeric | |piwFA |numeric | |piwFC |numeric | |piwFS |numeric | |piwKN |numeric | |piwSI |numeric | |piwSL |numeric | |piwXX |numeric | |piwCH/C |numeric | |piwCS/C |numeric | |piwCU/C |numeric | |piwFA/C |numeric | |piwFC/C |numeric | |piwFS/C |numeric | |piwKN/C |numeric | |piwSI/C |numeric | |piwSL/C |numeric | |piwXX/C |numeric | |piO-Swing% |numeric | |piZ-Swing% |numeric | |piSwing% |numeric | |piO-Contact% |numeric | |piZ-Contact% |numeric | |piContact% |numeric | |piZone% |numeric | |Events |numeric | |EV |numeric | |LA |numeric | |Barrels |numeric | |Barrel% |numeric | |maxEV |numeric | |HardHit |numeric | |HardHit% |numeric | |gamedate |character | |dh |integer |
try(fg_batter_game_logs(playerid = 19755, year = 2023))
try(fg_batter_game_logs(playerid = 19755, year = 2023))
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
fg_batter_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_batter_leaders( age = "", pos = "all", stats = "bat", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of batter data.
col_name | types |
Season | integer |
team_name | character |
Bats | character |
xMLBAMID | integer |
PlayerNameRoute | character |
PlayerName | character |
playerid | integer |
Age | integer |
AgeRng | character |
SeasonMin | integer |
SeasonMax | integer |
G | integer |
AB | integer |
PA | integer |
H | integer |
1B | integer |
2B | integer |
3B | integer |
HR | integer |
R | integer |
RBI | integer |
BB | integer |
IBB | integer |
SO | integer |
HBP | integer |
SF | integer |
SH | integer |
GDP | integer |
SB | integer |
CS | integer |
AVG | numeric |
GB | integer |
FB | integer |
LD | integer |
IFFB | integer |
Pitches | integer |
Balls | integer |
Strikes | integer |
IFH | integer |
BU | integer |
BUH | integer |
BB_pct | numeric |
K_pct | numeric |
BB_K | numeric |
OBP | numeric |
SLG | numeric |
OPS | numeric |
ISO | numeric |
BABIP | numeric |
GB_FB | numeric |
LD_pct | numeric |
GB_pct | numeric |
FB_pct | numeric |
IFFB_pct | numeric |
HR_FB | numeric |
IFH_pct | numeric |
BUH_pct | numeric |
TTO_pct | numeric |
wOBA | numeric |
wRAA | numeric |
wRC | numeric |
Batting | numeric |
Fielding | numeric |
Replacement | numeric |
Positional | numeric |
wLeague | numeric |
Defense | numeric |
Offense | numeric |
RAR | numeric |
WAR | numeric |
WAROld | numeric |
Dollars | numeric |
BaseRunning | numeric |
Spd | numeric |
wRC_plus | numeric |
wBsR | numeric |
WPA | numeric |
WPA_minus | numeric |
WPA_plus | numeric |
RE24 | numeric |
REW | numeric |
pLI | numeric |
PH | integer |
WPA_LI | numeric |
Clutch | numeric |
FBall_pct | numeric |
FBv | numeric |
SL_pct | numeric |
SLv | numeric |
CT_pct | numeric |
CTv | numeric |
CB_pct | numeric |
CBv | numeric |
CH_pct | numeric |
CHv | numeric |
SF_pct | numeric |
SFv | numeric |
XX_pct | numeric |
wFB | numeric |
wSL | numeric |
wCT | numeric |
wCB | numeric |
wCH | numeric |
wSF | numeric |
wFB_C | numeric |
wSL_C | numeric |
wCT_C | numeric |
wCB_C | numeric |
wCH_C | numeric |
wSF_C | numeric |
O-Swing_pct | numeric |
Z-Swing_pct | numeric |
Swing_pct | numeric |
O-Contact_pct | numeric |
Z-Contact_pct | numeric |
Contact_pct | numeric |
Zone_pct | numeric |
F-Strike_pct | numeric |
SwStr_pct | numeric |
CStr_pct | numeric |
C+SwStr_pct | numeric |
Pull | integer |
Cent | integer |
Oppo | integer |
Soft | integer |
Med | integer |
Hard | integer |
bipCount | integer |
Pull_pct | numeric |
Cent_pct | numeric |
Oppo_pct | numeric |
Soft_pct | numeric |
Med_pct | numeric |
Hard_pct | numeric |
UBR | numeric |
GDPRuns | numeric |
AVG+ | numeric |
BB_pct+ | numeric |
K_pct+ | numeric |
OBP+ | numeric |
SLG+ | numeric |
ISO+ | numeric |
BABIP+ | numeric |
LD_pct+ | numeric |
GB_pct+ | numeric |
FB_pct+ | numeric |
HRFB_pct+ | numeric |
Pull_pct+ | numeric |
Cent_pct+ | numeric |
Oppo_pct+ | numeric |
Soft_pct+ | numeric |
Med_pct+ | numeric |
Hard_pct+ | numeric |
xwOBA | numeric |
xAVG | numeric |
xSLG | numeric |
PPTV | integer |
CPTV | integer |
BPTV | integer |
DSV | integer |
DGV | integer |
BTV | integer |
rPPTV | numeric |
rBPTV | numeric |
EBV | integer |
ESV | integer |
rFTeamV | numeric |
rBTeamV | numeric |
rTV | numeric |
pfx_FA_pct | numeric |
pfx_FC_pct | numeric |
pfx_FS_pct | numeric |
pfx_FO_pct | numeric |
pfx_SI_pct | numeric |
pfx_SL_pct | numeric |
pfx_CU_pct | numeric |
pfx_KC_pct | numeric |
pfx_EP_pct | numeric |
pfx_CH_pct | numeric |
pfx_SC_pct | numeric |
pfx_vFA | numeric |
pfx_vFC | numeric |
pfx_vFS | numeric |
pfx_vFO | numeric |
pfx_vSI | numeric |
pfx_vSL | numeric |
pfx_vCU | numeric |
pfx_vKC | numeric |
pfx_vEP | numeric |
pfx_vCH | numeric |
pfx_vSC | numeric |
pfx_FA-X | numeric |
pfx_FC-X | numeric |
pfx_FS-X | numeric |
pfx_FO-X | numeric |
pfx_SI-X | numeric |
pfx_SL-X | numeric |
pfx_CU-X | numeric |
pfx_KC-X | numeric |
pfx_EP-X | numeric |
pfx_CH-X | numeric |
pfx_SC-X | numeric |
pfx_FA-Z | numeric |
pfx_FC-Z | numeric |
pfx_FS-Z | numeric |
pfx_FO-Z | numeric |
pfx_SI-Z | numeric |
pfx_SL-Z | numeric |
pfx_CU-Z | numeric |
pfx_KC-Z | numeric |
pfx_EP-Z | numeric |
pfx_CH-Z | numeric |
pfx_SC-Z | numeric |
pfx_wFA | numeric |
pfx_wFC | numeric |
pfx_wFS | numeric |
pfx_wFO | numeric |
pfx_wSI | numeric |
pfx_wSL | numeric |
pfx_wCU | numeric |
pfx_wKC | numeric |
pfx_wEP | numeric |
pfx_wCH | numeric |
pfx_wSC | numeric |
pfx_wFA_C | numeric |
pfx_wFC_C | numeric |
pfx_wFS_C | numeric |
pfx_wFO_C | numeric |
pfx_wSI_C | numeric |
pfx_wSL_C | numeric |
pfx_wCU_C | numeric |
pfx_wKC_C | numeric |
pfx_wEP_C | numeric |
pfx_wCH_C | numeric |
pfx_wSC_C | numeric |
pfx_O-Swing_pct | numeric |
pfx_Z-Swing_pct | numeric |
pfx_Swing_pct | numeric |
pfx_O-Contact_pct | numeric |
pfx_Z-Contact_pct | numeric |
pfx_Contact_pct | numeric |
pfx_Zone_pct | numeric |
pfx_Pace | numeric |
pi_CH_pct | numeric |
pi_CU_pct | numeric |
pi_FA_pct | numeric |
pi_FC_pct | numeric |
pi_FS_pct | numeric |
pi_SB_pct | numeric |
pi_SI_pct | numeric |
pi_SL_pct | numeric |
pi_vCH | numeric |
pi_vCU | numeric |
pi_vFA | numeric |
pi_vFC | numeric |
pi_vFS | numeric |
pi_vSB | numeric |
pi_vSI | numeric |
pi_vSL | numeric |
pi_CH-X | numeric |
pi_CU-X | numeric |
pi_FA-X | numeric |
pi_FC-X | numeric |
pi_FS-X | numeric |
pi_SB-X | numeric |
pi_SI-X | numeric |
pi_SL-X | numeric |
pi_CH-Z | numeric |
pi_CU-Z | numeric |
pi_FA-Z | numeric |
pi_FC-Z | numeric |
pi_FS-Z | numeric |
pi_SB-Z | numeric |
pi_SI-Z | numeric |
pi_SL-Z | numeric |
pi_wCH | numeric |
pi_wCU | numeric |
pi_wFA | numeric |
pi_wFC | numeric |
pi_wFS | numeric |
pi_wSB | numeric |
pi_wSI | numeric |
pi_wSL | numeric |
pi_wCH_C | numeric |
pi_wCU_C | numeric |
pi_wFA_C | numeric |
pi_wFC_C | numeric |
pi_wFS_C | numeric |
pi_wSB_C | numeric |
pi_wSI_C | numeric |
pi_wSL_C | numeric |
pi_O-Swing_pct | numeric |
pi_Z-Swing_pct | numeric |
pi_Swing_pct | numeric |
pi_O-Contact_pct | numeric |
pi_Z-Contact_pct | numeric |
pi_Contact_pct | numeric |
pi_Zone_pct | numeric |
pi_Pace | numeric |
Events | integer |
EV | numeric |
LA | numeric |
Barrels | integer |
Barrel_pct | numeric |
maxEV | numeric |
HardHit | integer |
HardHit_pct | numeric |
Q | numeric |
TG | integer |
TPA | integer |
team_name_abb | character |
teamid | integer |
Pos | numeric |
phLI | numeric |
pi_XX_pct | numeric |
pi_vXX | numeric |
pi_XX-X | numeric |
pi_XX-Z | numeric |
pi_wXX | numeric |
pi_wXX_C | numeric |
rBTV | numeric |
pi_CS_pct | numeric |
pi_vCS | numeric |
pi_CS-X | numeric |
pi_CS-Z | numeric |
pi_wCS | numeric |
pi_wCS_C | numeric |
KN_pct | numeric |
KNv | numeric |
wKN | numeric |
wKN_C | numeric |
pfx_KN_pct | numeric |
pfx_vKN | numeric |
pfx_KN-X | numeric |
pfx_KN-Z | numeric |
pfx_wKN | numeric |
pfx_wKN_C | numeric |
pi_KN_pct | numeric |
pi_vKN | numeric |
pi_KN-X | numeric |
pi_KN-Z | numeric |
pi_wKN | numeric |
pi_wKN_C | numeric |
rCPTV | numeric |
CFraming | numeric |
rDGV | numeric |
rDSV | numeric |
try(fg_batter_leaders(startseason = 2023, endseason = 2023))
try(fg_batter_leaders(startseason = 2023, endseason = 2023))
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
fg_fielder_leaders( age = "", pos = "all", stats = "fld", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "1", postseason = "", sortdir = "default", sortstat = "Defense" )
fg_fielder_leaders( age = "", pos = "all", stats = "fld", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "1", postseason = "", sortdir = "default", sortstat = "Defense" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "Defense". |
A data frame of fielder data.
col_name | types |
Season | integer |
team_name | character |
xMLBAMID | integer |
PlayerNameRoute | character |
PlayerName | character |
playerid | integer |
SeasonMin | integer |
SeasonMax | integer |
Pos | character |
G | integer |
GS | integer |
Inn | numeric |
PO | integer |
A | integer |
E | integer |
FE | integer |
TE | integer |
DP | integer |
DPS | integer |
DPT | integer |
DPF | integer |
SB | integer |
CS | integer |
PB | integer |
WP | integer |
FP | numeric |
rSB | integer |
rGFP | integer |
rSZ | numeric |
rCERA | integer |
DRS | integer |
Defense | numeric |
CStrikes | numeric |
CFraming | numeric |
Q | numeric |
TInn | numeric |
teamid | integer |
team_name_abb | character |
rARM | integer |
rPM | integer |
BIZ | integer |
Plays | integer |
RZR | numeric |
OOZ | integer |
ARM | numeric |
RngR | numeric |
ErrR | numeric |
UZR | numeric |
UZR_150 | numeric |
OAA | integer |
rFRP | integer |
rGDP | integer |
DPR | numeric |
Scp | integer |
try(fg_fielder_leaders(startseason = 2023, endseason = 2023))
try(fg_fielder_leaders(startseason = 2023, endseason = 2023))
Scrape historical FanGraphs Guts! table, wOBA, FIP coefficients and constants
fg_guts()
fg_guts()
Returns a tibble of seasonal constants from FanGraphs
col_name | types |
season | integer |
lg_woba | numeric |
woba_scale | numeric |
wBB | numeric |
wHBP | numeric |
w1B | numeric |
w2B | numeric |
w3B | numeric |
wHR | numeric |
runSB | numeric |
runCS | numeric |
lg_r_pa | numeric |
lg_r_w | numeric |
cFIP | numeric |
try(fg_guts())
try(fg_guts())
This function allows you to scrape MiLB game logs for individual batters from FanGraphs.
fg_milb_batter_game_logs(playerid, year)
fg_milb_batter_game_logs(playerid, year)
playerid |
The batter's minor league ID from FanGraphs. |
year |
The season for which game logs should be returned. |
Returns a tibble of Minor League batter game logs with the following columns:
col_name | types |
player_name | character |
minor_playerid | character |
Date | character |
Team | character |
Level | character |
Opp | character |
G | numeric |
AB | numeric |
PA | numeric |
H | numeric |
1B | numeric |
2B | numeric |
3B | numeric |
HR | numeric |
R | numeric |
RBI | numeric |
BB | numeric |
IBB | numeric |
SO | numeric |
HBP | numeric |
SF | numeric |
SH | numeric |
GDP | numeric |
SB | numeric |
CS | numeric |
AVG | numeric |
BB% | numeric |
K% | numeric |
BB/K | numeric |
OBP | numeric |
SLG | numeric |
OPS | numeric |
ISO | numeric |
Spd | numeric |
BABIP | numeric |
wRC | numeric |
wRAA | numeric |
wOBA | numeric |
wRC+ | numeric |
wBsR | numeric |
gamedate | character |
dh | integer |
UPId | character |
MLBAMId | character |
MinorMasterId | character |
RRId | character |
FirstName | character |
LastName | character |
firstLastName | character |
Height | character |
Weight | character |
BirthDate | character |
Bats | character |
Throws | character |
Position | character |
BirthCity | character |
College | character |
Age | character |
try(fg_milb_batter_game_logs(playerid = "sa3019999", year=2023))
try(fg_milb_batter_game_logs(playerid = "sa3019999", year=2023))
This function allows you to scrape MiLB game logs for individual batters from FanGraphs.com.
fg_milb_pitcher_game_logs(playerid, year)
fg_milb_pitcher_game_logs(playerid, year)
playerid |
The pitcher's minor league ID from FanGraphs.com. |
year |
The season for which game logs should be returned. |
Returns a tibble of Minor League pitcher game logs.
col_name | types |
player_name | character |
minor_playerid | character |
Date | character |
Team | character |
Level | character |
Opp | character |
W | numeric |
L | numeric |
ERA | numeric |
G | numeric |
GS | numeric |
CG | numeric |
ShO | numeric |
SV | numeric |
IP | numeric |
TBF | numeric |
H | numeric |
R | numeric |
ER | numeric |
HR | numeric |
BB | numeric |
IBB | numeric |
HBP | numeric |
WP | numeric |
BK | numeric |
SO | numeric |
K/9 | numeric |
BB/9 | numeric |
K/BB | numeric |
HR/9 | numeric |
K% | numeric |
K-BB% | numeric |
BB% | numeric |
AVG | numeric |
WHIP | numeric |
BABIP | numeric |
LOB% | numeric |
FIP | numeric |
gamedate | character |
dh | integer |
UPId | character |
MLBAMId | character |
MinorMasterId | character |
RRId | character |
FirstName | character |
LastName | character |
firstLastName | character |
Height | character |
Weight | character |
BirthDate | character |
Bats | character |
Throws | character |
Position | character |
BirthCity | character |
College | character |
Age | character |
try(fg_milb_pitcher_game_logs(playerid = "sa3020682", year=2023))
try(fg_milb_pitcher_game_logs(playerid = "sa3020682", year=2023))
This function allows you to scrape park factors for a given season from FanGraphs.com.
This function allows you to scrape park factors by handedness from FanGraphs.com for a given single year.
fg_park(yr) fg_park_hand(yr)
fg_park(yr) fg_park_hand(yr)
yr |
Season for which you want to scrape the park factors. |
Returns a tibble of park factors.
col_name | types |
season | integer |
home_team | character |
basic_5yr | integer |
3yr | integer |
1yr | integer |
single | integer |
double | integer |
triple | integer |
hr | integer |
so | integer |
UIBB | integer |
GB | integer |
FB | integer |
LD | integer |
IFFB | integer |
FIP | integer |
Returns a tibble of park factors by handedness.
col_name | types |
season | integer |
home_team | character |
single_as_LHH | integer |
single_as_RHH | integer |
double_as_LHH | integer |
double_as_RHH | integer |
triple_as_LHH | integer |
triple_as_RHH | integer |
hr_as_LHH | integer |
hr_as_RHH | integer |
try(fg_park(2013)) try(fg_park_hand(2013))
try(fg_park(2013)) try(fg_park_hand(2013))
(legacy) Scrape Pitcher Leaderboards from FanGraphs
fg_pitch_leaders( age = "", pos = "all", stats = "pit", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_pitch_leaders( age = "", pos = "all", stats = "pit", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of pitcher data.
This function allows you to scrape game logs by year for a pitcher from FanGraphs.com.
fg_pitcher_game_logs(playerid, year)
fg_pitcher_game_logs(playerid, year)
playerid |
This is the playerid used by FanGraphs for a given player |
year |
The season for which game logs should be returned (use the YYYY format) |
Returns a tibble of pitcher game logs with the following columns:
col_name | types |
PlayerName | character |
playerid | integer |
Date | character |
Opp | character |
teamid | integer |
season | integer |
Team | character |
HomeAway | character |
Age | integer |
W | numeric |
L | numeric |
ERA | numeric |
G | numeric |
GS | numeric |
CG | numeric |
ShO | numeric |
SV | numeric |
HLD | numeric |
BS | numeric |
IP | numeric |
TBF | numeric |
H | numeric |
R | numeric |
ER | numeric |
HR | numeric |
BB | numeric |
IBB | numeric |
HBP | numeric |
WP | numeric |
BK | numeric |
SO | numeric |
K/9 | numeric |
BB/9 | numeric |
H/9 | numeric |
K/BB | numeric |
IFH% | numeric |
BUH% | numeric |
GB | numeric |
FB | numeric |
LD | numeric |
IFFB | numeric |
IFH | numeric |
BU | numeric |
BUH | numeric |
K% | numeric |
BB% | numeric |
K-BB% | numeric |
SIERA | numeric |
HR/9 | numeric |
AVG | numeric |
WHIP | numeric |
BABIP | numeric |
LOB% | numeric |
FIP | numeric |
E-F | numeric |
xFIP | numeric |
ERA- | numeric |
FIP- | numeric |
xFIP- | numeric |
GB/FB | numeric |
LD% | numeric |
GB% | numeric |
FB% | numeric |
IFFB% | numeric |
HR/FB | numeric |
RS | numeric |
RS/9 | numeric |
Balls | numeric |
Strikes | numeric |
Pitches | numeric |
WPA | numeric |
-WPA | numeric |
+WPA | numeric |
RE24 | numeric |
REW | numeric |
pLI | numeric |
inLI | numeric |
gmLI | numeric |
exLI | numeric |
Pulls | numeric |
Games | numeric |
WPA/LI | numeric |
Clutch | numeric |
SD | numeric |
MD | numeric |
FB%1 | numeric |
FBv | numeric |
SL% | numeric |
SLv | numeric |
CT% | numeric |
CTv | numeric |
CB% | numeric |
CBv | numeric |
CH% | numeric |
CHv | numeric |
XX% | numeric |
PO% | numeric |
wFB | numeric |
wSL | numeric |
wCT | numeric |
wCB | numeric |
wCH | numeric |
wFB/C | numeric |
wSL/C | numeric |
wCT/C | numeric |
wCB/C | numeric |
wCH/C | numeric |
O-Swing% | numeric |
Z-Swing% | numeric |
Swing% | numeric |
O-Contact% | numeric |
Z-Contact% | numeric |
Contact% | numeric |
Zone% | numeric |
F-Strike% | numeric |
SwStr% | numeric |
Pull | numeric |
Cent | numeric |
Oppo | numeric |
Soft | numeric |
Med | numeric |
Hard | numeric |
bipCount | numeric |
Pull% | numeric |
Cent% | numeric |
Oppo% | numeric |
Soft% | numeric |
Med% | numeric |
Hard% | numeric |
tERA | numeric |
GSv2 | numeric |
Events | numeric |
gamedate | character |
dh | integer |
try(fg_pitcher_game_logs(playerid = "19755", year = 2023))
try(fg_pitcher_game_logs(playerid = "19755", year = 2023))
Scrape Pitcher Leaderboards from FanGraphs
fg_pitcher_leaders( age = "", pos = "all", stats = "pit", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_pitcher_leaders( age = "", pos = "all", stats = "pit", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0", pageitems = "10000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of pitcher data.
col_name | types |
Season | integer |
team_name | character |
Throws | character |
xMLBAMID | integer |
PlayerNameRoute | character |
PlayerName | character |
playerid | integer |
Age | integer |
AgeRng | character |
SeasonMin | integer |
SeasonMax | integer |
W | integer |
L | integer |
ERA | numeric |
G | integer |
GS | integer |
CG | integer |
ShO | integer |
SV | integer |
BS | integer |
IP | numeric |
TBF | integer |
H | integer |
R | integer |
ER | integer |
HR | integer |
BB | integer |
IBB | integer |
HBP | integer |
WP | integer |
BK | integer |
SO | integer |
GB | integer |
FB | integer |
LD | integer |
IFFB | integer |
Pitches | integer |
Balls | integer |
Strikes | integer |
RS | integer |
IFH | integer |
BU | integer |
BUH | integer |
K_9 | numeric |
BB_9 | numeric |
K_BB | numeric |
H_9 | numeric |
HR_9 | numeric |
AVG | numeric |
WHIP | numeric |
BABIP | numeric |
LOB_pct | numeric |
FIP | numeric |
GB_FB | numeric |
LD_pct | numeric |
GB_pct | numeric |
FB_pct | numeric |
IFFB_pct | numeric |
HR_FB | numeric |
IFH_pct | numeric |
BUH_pct | numeric |
TTO_pct | numeric |
CFraming | numeric |
Starting | numeric |
Start_IP | numeric |
RAR | numeric |
WAR | numeric |
Dollars | numeric |
RA9-Wins | numeric |
LOB-Wins | numeric |
BIP-Wins | numeric |
BS-Wins | numeric |
tERA | numeric |
xFIP | numeric |
WPA | numeric |
WPA_minus | numeric |
WPA_plus | numeric |
RE24 | numeric |
REW | numeric |
pLI | numeric |
inLI | numeric |
gmLI | numeric |
exLI | numeric |
Pulls | integer |
Games | integer |
WPA_LI | numeric |
Clutch | numeric |
FBall_pct | numeric |
FBv | numeric |
SL_pct | numeric |
SLv | numeric |
CT_pct | numeric |
CTv | numeric |
CB_pct | numeric |
CBv | numeric |
SF_pct | numeric |
SFv | numeric |
XX_pct | numeric |
wFB | numeric |
wSL | numeric |
wCT | numeric |
wCB | numeric |
wSF | numeric |
wFB_C | numeric |
wSL_C | numeric |
wCT_C | numeric |
wCB_C | numeric |
wSF_C | numeric |
O-Swing_pct | numeric |
Z-Swing_pct | numeric |
Swing_pct | numeric |
O-Contact_pct | numeric |
Z-Contact_pct | numeric |
Contact_pct | numeric |
Zone_pct | numeric |
F-Strike_pct | numeric |
SwStr_pct | numeric |
CStr_pct | numeric |
C+SwStr_pct | numeric |
HLD | integer |
SD | integer |
MD | integer |
ERA- | numeric |
FIP- | numeric |
xFIP- | numeric |
K_pct | numeric |
BB_pct | numeric |
K-BB_pct | numeric |
SIERA | numeric |
kwERA | numeric |
RS_9 | numeric |
E-F | numeric |
Pull | integer |
Cent | integer |
Oppo | integer |
Soft | integer |
Med | integer |
Hard | integer |
bipCount | integer |
Pull_pct | numeric |
Cent_pct | numeric |
Oppo_pct | numeric |
Soft_pct | numeric |
Med_pct | numeric |
Hard_pct | numeric |
K_9+ | numeric |
BB_9+ | numeric |
K_BB+ | numeric |
H_9+ | numeric |
HR_9+ | numeric |
AVG+ | numeric |
WHIP+ | numeric |
BABIP+ | numeric |
LOB_pct+ | numeric |
K_pct+ | numeric |
BB_pct+ | numeric |
LD_pct+ | numeric |
GB_pct+ | numeric |
FB_pct+ | numeric |
HRFB_pct+ | numeric |
Pull_pct+ | numeric |
Cent_pct+ | numeric |
Oppo_pct+ | numeric |
Soft_pct+ | numeric |
Med_pct+ | numeric |
Hard_pct+ | numeric |
xERA | numeric |
pb_o_CH | numeric |
pb_s_CH | numeric |
pb_c_CH | numeric |
pb_o_CU | numeric |
pb_s_CU | numeric |
pb_c_CU | numeric |
pb_o_FF | numeric |
pb_s_FF | numeric |
pb_c_FF | numeric |
pb_o_SI | numeric |
pb_s_SI | numeric |
pb_c_SI | numeric |
pb_o_SL | numeric |
pb_s_SL | numeric |
pb_c_SL | numeric |
pb_overall | numeric |
pb_stuff | numeric |
pb_command | numeric |
pb_xRV100 | numeric |
pb_ERA | numeric |
sp_s_CH | numeric |
sp_l_CH | numeric |
sp_p_CH | numeric |
sp_s_CU | numeric |
sp_l_CU | numeric |
sp_p_CU | numeric |
sp_s_FF | numeric |
sp_l_FF | numeric |
sp_p_FF | numeric |
sp_s_SI | numeric |
sp_l_SI | numeric |
sp_p_SI | numeric |
sp_s_SL | numeric |
sp_l_SL | numeric |
sp_p_SL | numeric |
sp_stuff | numeric |
sp_location | numeric |
sp_pitching | numeric |
PPTV | integer |
CPTV | integer |
BPTV | integer |
DSV | integer |
DGV | integer |
BTV | integer |
rPPTV | numeric |
rBPTV | numeric |
EBV | integer |
ESV | integer |
rFTeamV | numeric |
rBTeamV | numeric |
rTV | numeric |
pfx_FA_pct | numeric |
pfx_SI_pct | numeric |
pfx_SL_pct | numeric |
pfx_CU_pct | numeric |
pfx_CH_pct | numeric |
pfx_vFA | numeric |
pfx_vSI | numeric |
pfx_vSL | numeric |
pfx_vCU | numeric |
pfx_vCH | numeric |
pfx_FA-X | numeric |
pfx_SI-X | numeric |
pfx_SL-X | numeric |
pfx_CU-X | numeric |
pfx_CH-X | numeric |
pfx_FA-Z | numeric |
pfx_SI-Z | numeric |
pfx_SL-Z | numeric |
pfx_CU-Z | numeric |
pfx_CH-Z | numeric |
pfx_wFA | numeric |
pfx_wSI | numeric |
pfx_wSL | numeric |
pfx_wCU | numeric |
pfx_wCH | numeric |
pfx_wFA_C | numeric |
pfx_wSI_C | numeric |
pfx_wSL_C | numeric |
pfx_wCU_C | numeric |
pfx_wCH_C | numeric |
pfx_O-Swing_pct | numeric |
pfx_Z-Swing_pct | numeric |
pfx_Swing_pct | numeric |
pfx_O-Contact_pct | numeric |
pfx_Z-Contact_pct | numeric |
pfx_Contact_pct | numeric |
pfx_Zone_pct | numeric |
pfx_Pace | numeric |
pi_CH_pct | numeric |
pi_CU_pct | numeric |
pi_FA_pct | numeric |
pi_SI_pct | numeric |
pi_SL_pct | numeric |
pi_vCH | numeric |
pi_vCU | numeric |
pi_vFA | numeric |
pi_vSI | numeric |
pi_vSL | numeric |
pi_CH-X | numeric |
pi_CU-X | numeric |
pi_FA-X | numeric |
pi_SI-X | numeric |
pi_SL-X | numeric |
pi_CH-Z | numeric |
pi_CU-Z | numeric |
pi_FA-Z | numeric |
pi_SI-Z | numeric |
pi_SL-Z | numeric |
pi_wCH | numeric |
pi_wCU | numeric |
pi_wFA | numeric |
pi_wSI | numeric |
pi_wSL | numeric |
pi_wCH_C | numeric |
pi_wCU_C | numeric |
pi_wFA_C | numeric |
pi_wSI_C | numeric |
pi_wSL_C | numeric |
pi_O-Swing_pct | numeric |
pi_Z-Swing_pct | numeric |
pi_Swing_pct | numeric |
pi_O-Contact_pct | numeric |
pi_Z-Contact_pct | numeric |
pi_Contact_pct | numeric |
pi_Zone_pct | numeric |
pi_Pace | numeric |
Events | integer |
EV | numeric |
LA | numeric |
Barrels | integer |
Barrel_pct | numeric |
maxEV | numeric |
HardHit | integer |
HardHit_pct | numeric |
Q | numeric |
TG | integer |
TIP | numeric |
team_name_abb | character |
teamid | integer |
CH_pct | numeric |
CHv | numeric |
wCH | numeric |
wCH_C | numeric |
pb_o_FS | numeric |
pb_s_FS | numeric |
pb_c_FS | numeric |
sp_s_FS | numeric |
sp_l_FS | numeric |
sp_p_FS | numeric |
pfx_FS_pct | numeric |
pfx_vFS | numeric |
pfx_FS-X | numeric |
pfx_FS-Z | numeric |
pfx_wFS | numeric |
pfx_wFS_C | numeric |
pi_FS_pct | numeric |
pi_vFS | numeric |
pi_FS-X | numeric |
pi_FS-Z | numeric |
pi_wFS | numeric |
pi_wFS_C | numeric |
pb_o_FC | numeric |
pb_s_FC | numeric |
pb_c_FC | numeric |
sp_s_FC | numeric |
sp_l_FC | numeric |
sp_p_FC | numeric |
pfx_FC_pct | numeric |
pfx_vFC | numeric |
pfx_FC-X | numeric |
pfx_FC-Z | numeric |
pfx_wFC | numeric |
pfx_wFC_C | numeric |
pi_FC_pct | numeric |
pi_vFC | numeric |
pi_FC-X | numeric |
pi_FC-Z | numeric |
pi_wFC | numeric |
pi_wFC_C | numeric |
pb_o_KC | numeric |
pb_s_KC | numeric |
pb_c_KC | numeric |
sp_s_KC | numeric |
sp_l_KC | numeric |
sp_p_KC | numeric |
rBTV | numeric |
pfx_KC_pct | numeric |
pfx_vKC | numeric |
pfx_KC-X | numeric |
pfx_KC-Z | numeric |
pfx_wKC | numeric |
pfx_wKC_C | numeric |
rCPTV | numeric |
KN_pct | numeric |
KNv | numeric |
wKN | numeric |
wKN_C | numeric |
pfx_KN_pct | numeric |
pfx_vKN | numeric |
pfx_KN-X | numeric |
pfx_KN-Z | numeric |
pfx_wKN | numeric |
pfx_wKN_C | numeric |
pi_KN_pct | numeric |
pi_XX_pct | numeric |
pi_vKN | numeric |
pi_vXX | numeric |
pi_KN-X | numeric |
pi_XX-X | numeric |
pi_KN-Z | numeric |
pi_XX-Z | numeric |
pi_wKN | numeric |
pi_wXX | numeric |
pi_wKN_C | numeric |
pi_wXX_C | numeric |
sp_s_FO | numeric |
sp_l_FO | numeric |
sp_p_FO | numeric |
pfx_FO_pct | numeric |
pfx_vFO | numeric |
pfx_FO-X | numeric |
pfx_FO-Z | numeric |
pfx_wFO | numeric |
pfx_wFO_C | numeric |
rDGV | numeric |
pi_CS_pct | numeric |
pi_vCS | numeric |
pi_CS-X | numeric |
pi_CS-Z | numeric |
pi_wCS | numeric |
pi_wCS_C | numeric |
Relieving | numeric |
Relief_IP | numeric |
rDSV | numeric |
pfx_EP_pct | numeric |
pfx_vEP | numeric |
pfx_EP-X | numeric |
pfx_EP-Z | numeric |
pfx_wEP | numeric |
pfx_wEP_C | numeric |
pfx_SC_pct | numeric |
pfx_vSC | numeric |
pfx_SC-X | numeric |
pfx_SC-Z | numeric |
pfx_wSC | numeric |
pfx_wSC_C | numeric |
pi_SB_pct | numeric |
pi_vSB | numeric |
pi_SB-X | numeric |
pi_SB-Z | numeric |
pi_wSB | numeric |
pi_wSB_C | numeric |
try(fg_pitcher_leaders(startseason = 2023, endseason = 2023))
try(fg_pitcher_leaders(startseason = 2023, endseason = 2023))
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
fg_team_batter( age = "", pos = "all", stats = "bat", lg = "all", qual = "y", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_team_batter( age = "", pos = "all", stats = "bat", lg = "all", qual = "y", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of batter data.
col_name | types |
Season | integer |
team_name | character |
SeasonMin | integer |
SeasonMax | integer |
G | integer |
AB | integer |
PA | integer |
H | integer |
1B | integer |
2B | integer |
3B | integer |
HR | integer |
R | integer |
RBI | integer |
BB | integer |
IBB | integer |
SO | integer |
HBP | integer |
SF | integer |
SH | integer |
GDP | integer |
SB | integer |
CS | integer |
AVG | numeric |
GB | integer |
FB | integer |
LD | integer |
IFFB | integer |
Pitches | integer |
Balls | integer |
Strikes | integer |
IFH | integer |
BU | integer |
BUH | integer |
BB_pct | numeric |
K_pct | numeric |
BB_K | numeric |
OBP | numeric |
SLG | numeric |
OPS | numeric |
ISO | numeric |
BABIP | numeric |
GB_FB | numeric |
LD_pct | numeric |
GB_pct | numeric |
FB_pct | numeric |
IFFB_pct | numeric |
HR_FB | numeric |
IFH_pct | numeric |
BUH_pct | numeric |
TTO_pct | numeric |
wOBA | numeric |
wRAA | numeric |
wRC | numeric |
Batting | numeric |
Fielding | numeric |
Replacement | numeric |
Positional | numeric |
wLeague | numeric |
CFraming | numeric |
Defense | numeric |
Offense | numeric |
RAR | numeric |
WAR | numeric |
WAROld | numeric |
Dollars | numeric |
BaseRunning | numeric |
Spd | numeric |
wRC_plus | numeric |
wBsR | numeric |
WPA | numeric |
WPA_minus | numeric |
WPA_plus | numeric |
RE24 | numeric |
REW | numeric |
pLI | numeric |
phLI | numeric |
PH | integer |
WPA_LI | numeric |
Clutch | numeric |
FBall_pct | numeric |
FBv | numeric |
SL_pct | numeric |
SLv | numeric |
CT_pct | numeric |
CTv | numeric |
CB_pct | numeric |
CBv | numeric |
CH_pct | numeric |
CHv | numeric |
SF_pct | numeric |
SFv | numeric |
KN_pct | numeric |
KNv | numeric |
XX_pct | numeric |
wFB | numeric |
wSL | numeric |
wCT | numeric |
wCB | numeric |
wCH | numeric |
wSF | numeric |
wKN | numeric |
wFB_C | numeric |
wSL_C | numeric |
wCT_C | numeric |
wCB_C | numeric |
wCH_C | numeric |
wSF_C | numeric |
wKN_C | numeric |
O-Swing_pct | numeric |
Z-Swing_pct | numeric |
Swing_pct | numeric |
O-Contact_pct | numeric |
Z-Contact_pct | numeric |
Contact_pct | numeric |
Zone_pct | numeric |
F-Strike_pct | numeric |
SwStr_pct | numeric |
CStr_pct | numeric |
C+SwStr_pct | numeric |
Pull | integer |
Cent | integer |
Oppo | integer |
Soft | integer |
Med | integer |
Hard | integer |
bipCount | integer |
Pull_pct | numeric |
Cent_pct | numeric |
Oppo_pct | numeric |
Soft_pct | numeric |
Med_pct | numeric |
Hard_pct | numeric |
UBR | numeric |
GDPRuns | numeric |
AVG+ | numeric |
BB_pct+ | numeric |
K_pct+ | numeric |
OBP+ | numeric |
SLG+ | numeric |
ISO+ | numeric |
BABIP+ | numeric |
LD_pct+ | numeric |
GB_pct+ | numeric |
FB_pct+ | numeric |
HRFB_pct+ | numeric |
Pull_pct+ | numeric |
Cent_pct+ | numeric |
Oppo_pct+ | numeric |
Soft_pct+ | numeric |
Med_pct+ | numeric |
Hard_pct+ | numeric |
rFTeamV | integer |
rBTeamV | integer |
rTV | integer |
pfx_FA_pct | numeric |
pfx_FT_pct | numeric |
pfx_FC_pct | numeric |
pfx_FS_pct | numeric |
pfx_FO_pct | numeric |
pfx_SI_pct | numeric |
pfx_SL_pct | numeric |
pfx_CU_pct | numeric |
pfx_KC_pct | numeric |
pfx_EP_pct | numeric |
pfx_CH_pct | numeric |
pfx_KN_pct | numeric |
pfx_vFA | numeric |
pfx_vFT | numeric |
pfx_vFC | numeric |
pfx_vFS | numeric |
pfx_vFO | numeric |
pfx_vSI | numeric |
pfx_vSL | numeric |
pfx_vCU | numeric |
pfx_vKC | numeric |
pfx_vEP | numeric |
pfx_vCH | numeric |
pfx_vKN | numeric |
pfx_FA-X | numeric |
pfx_FT-X | numeric |
pfx_FC-X | numeric |
pfx_FS-X | numeric |
pfx_FO-X | numeric |
pfx_SI-X | numeric |
pfx_SL-X | numeric |
pfx_CU-X | numeric |
pfx_KC-X | numeric |
pfx_EP-X | numeric |
pfx_CH-X | numeric |
pfx_KN-X | numeric |
pfx_FA-Z | numeric |
pfx_FT-Z | numeric |
pfx_FC-Z | numeric |
pfx_FS-Z | numeric |
pfx_FO-Z | numeric |
pfx_SI-Z | numeric |
pfx_SL-Z | numeric |
pfx_CU-Z | numeric |
pfx_KC-Z | numeric |
pfx_EP-Z | numeric |
pfx_CH-Z | numeric |
pfx_KN-Z | numeric |
pfx_wFA | numeric |
pfx_wFT | numeric |
pfx_wFC | numeric |
pfx_wFS | numeric |
pfx_wFO | numeric |
pfx_wSI | numeric |
pfx_wSL | numeric |
pfx_wCU | numeric |
pfx_wKC | numeric |
pfx_wEP | numeric |
pfx_wCH | numeric |
pfx_wKN | numeric |
pfx_wFA_C | numeric |
pfx_wFT_C | numeric |
pfx_wFC_C | numeric |
pfx_wFS_C | numeric |
pfx_wFO_C | numeric |
pfx_wSI_C | numeric |
pfx_wSL_C | numeric |
pfx_wCU_C | numeric |
pfx_wKC_C | numeric |
pfx_wEP_C | numeric |
pfx_wCH_C | numeric |
pfx_wKN_C | numeric |
pfx_O-Swing_pct | numeric |
pfx_Z-Swing_pct | numeric |
pfx_Swing_pct | numeric |
pfx_O-Contact_pct | numeric |
pfx_Z-Contact_pct | numeric |
pfx_Contact_pct | numeric |
pfx_Zone_pct | numeric |
pfx_Pace | numeric |
pi_CH_pct | numeric |
pi_CS_pct | numeric |
pi_CU_pct | numeric |
pi_FA_pct | numeric |
pi_FC_pct | numeric |
pi_FS_pct | numeric |
pi_KN_pct | numeric |
pi_SI_pct | numeric |
pi_SL_pct | numeric |
pi_XX_pct | numeric |
pi_vCH | numeric |
pi_vCS | numeric |
pi_vCU | numeric |
pi_vFA | numeric |
pi_vFC | numeric |
pi_vFS | numeric |
pi_vKN | numeric |
pi_vSI | numeric |
pi_vSL | numeric |
pi_vXX | numeric |
pi_CH-X | numeric |
pi_CS-X | numeric |
pi_CU-X | numeric |
pi_FA-X | numeric |
pi_FC-X | numeric |
pi_FS-X | numeric |
pi_KN-X | numeric |
pi_SI-X | numeric |
pi_SL-X | numeric |
pi_XX-X | numeric |
pi_CH-Z | numeric |
pi_CS-Z | numeric |
pi_CU-Z | numeric |
pi_FA-Z | numeric |
pi_FC-Z | numeric |
pi_FS-Z | numeric |
pi_KN-Z | numeric |
pi_SI-Z | numeric |
pi_SL-Z | numeric |
pi_XX-Z | numeric |
pi_wCH | numeric |
pi_wCS | numeric |
pi_wCU | numeric |
pi_wFA | numeric |
pi_wFC | numeric |
pi_wFS | numeric |
pi_wKN | numeric |
pi_wSI | numeric |
pi_wSL | numeric |
pi_wXX | numeric |
pi_wCH_C | numeric |
pi_wCS_C | numeric |
pi_wCU_C | numeric |
pi_wFA_C | numeric |
pi_wFC_C | numeric |
pi_wFS_C | numeric |
pi_wKN_C | numeric |
pi_wSI_C | numeric |
pi_wSL_C | numeric |
pi_wXX_C | numeric |
pi_O-Swing_pct | numeric |
pi_Z-Swing_pct | numeric |
pi_Swing_pct | numeric |
pi_O-Contact_pct | numeric |
pi_Z-Contact_pct | numeric |
pi_Contact_pct | numeric |
pi_Zone_pct | numeric |
pi_Pace | numeric |
Events | integer |
EV | numeric |
LA | numeric |
Barrels | integer |
Barrel_pct | numeric |
maxEV | numeric |
HardHit | integer |
HardHit_pct | numeric |
Q | numeric |
TG | integer |
TPA | integer |
team_name_abb | character |
teamid | integer |
Pos | numeric |
pi_SB_pct | numeric |
pi_vSB | numeric |
pi_SB-X | numeric |
pi_SB-Z | numeric |
pi_wSB | numeric |
pi_wSB_C | numeric |
pfx_SC_pct | numeric |
pfx_vSC | numeric |
pfx_SC-X | numeric |
pfx_SC-Z | numeric |
pfx_wSC | numeric |
pfx_wSC_C | numeric |
try(fg_team_batter(startseason = 2015, endseason = 2015, qual = 200))
try(fg_team_batter(startseason = 2015, endseason = 2015, qual = 200))
Scrape Team Fielder Leaderboards from FanGraphs
fg_team_fielder( age = "", pos = "all", stats = "fld", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "1", postseason = "", sortdir = "default", sortstat = "Defense" )
fg_team_fielder( age = "", pos = "all", stats = "fld", lg = "all", qual = "0", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "1", postseason = "", sortdir = "default", sortstat = "Defense" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "Defense". |
A data frame of fielder data.
col_name | types |
Season | integer |
team_name | character |
SeasonMin | integer |
SeasonMax | integer |
Pos | character |
G | integer |
GS | integer |
Inn | integer |
PO | integer |
A | integer |
E | integer |
FE | integer |
TE | integer |
DP | integer |
DPS | integer |
DPT | integer |
DPF | integer |
Scp | integer |
SB | integer |
CS | integer |
PB | integer |
WP | integer |
FP | numeric |
rSB | integer |
rGDP | integer |
rARM | integer |
rGFP | integer |
rPM | integer |
rSZ | numeric |
rTS | integer |
rCERA | integer |
DRS | integer |
BIZ | integer |
Plays | integer |
RZR | numeric |
OOZ | integer |
ARM | numeric |
DPR | numeric |
RngR | numeric |
ErrR | numeric |
UZR | numeric |
UZR_150 | numeric |
Defense | numeric |
CStrikes | numeric |
CFraming | numeric |
OAA | integer |
rFRP | integer |
Q | numeric |
TInn | numeric |
teamid | integer |
team_name_abb | character |
try(fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150))
try(fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150))
Scrape Team Pitcher Leaderboards from FanGraphs
fg_team_pitcher( age = "", pos = "all", stats = "pit", lg = "all", qual = "y", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
fg_team_pitcher( age = "", pos = "all", stats = "pit", lg = "all", qual = "y", startseason = "2023", endseason = "2023", startdate = "", enddate = "", month = "0", hand = "", team = "0,ts", pageitems = "1000", pagenum = "1", ind = "0", rost = "0", players = "", type = "8", postseason = "", sortdir = "default", sortstat = "WAR" )
age |
(integer) Age of players |
pos |
(character) Position of players, defaults to "all". To exclude pitchers, use "np". |
stats |
(character) Statistic to return. Defaults to "bat". |
lg |
(character) League to return. Defaults to "all". Options are "al", "nl", or "all". |
qual |
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y". |
startseason |
(character) Season for which you want to scrape the data. |
endseason |
(character) Last season for which you want data. |
startdate |
(character) Start date for which you want data. |
enddate |
(character) End date for which you want data. |
month |
(character) Month for which you want data. |
hand |
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all. |
team |
(character) Teams for which you want data, comma separated. |
pageitems |
(character) Number of items per page. |
pagenum |
(character) Page number. |
ind |
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons. |
rost |
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude. |
players |
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude. |
type |
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page. |
postseason |
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason. |
sortdir |
(character) Sort direction. Options are "asc" or "desc" or "default". |
sortstat |
(character) Sort by stat. Default is "WAR". |
A data frame of pitcher data.
col_name | types |
Season | integer |
team_name | character |
SeasonMin | integer |
SeasonMax | integer |
W | integer |
L | integer |
ERA | numeric |
G | integer |
GS | integer |
CG | integer |
ShO | integer |
SV | integer |
BS | integer |
IP | numeric |
TBF | integer |
H | integer |
R | integer |
ER | integer |
HR | integer |
BB | integer |
IBB | integer |
HBP | integer |
WP | integer |
BK | integer |
SO | integer |
GB | integer |
FB | integer |
LD | integer |
IFFB | integer |
Pitches | integer |
Balls | integer |
Strikes | integer |
RS | integer |
IFH | integer |
BU | integer |
BUH | integer |
K_9 | numeric |
BB_9 | numeric |
K_BB | numeric |
H_9 | numeric |
HR_9 | numeric |
AVG | numeric |
WHIP | numeric |
BABIP | numeric |
LOB_pct | numeric |
FIP | numeric |
GB_FB | numeric |
LD_pct | numeric |
GB_pct | numeric |
FB_pct | numeric |
IFFB_pct | numeric |
HR_FB | numeric |
IFH_pct | numeric |
BUH_pct | numeric |
TTO_pct | numeric |
CFraming | numeric |
Starting | numeric |
Start_IP | numeric |
Relieving | numeric |
Relief_IP | numeric |
RAR | numeric |
WAR | numeric |
Dollars | numeric |
RA9-Wins | numeric |
LOB-Wins | numeric |
BIP-Wins | numeric |
BS-Wins | numeric |
tERA | numeric |
xFIP | numeric |
WPA | numeric |
WPA_minus | numeric |
WPA_plus | numeric |
RE24 | numeric |
REW | numeric |
pLI | numeric |
inLI | numeric |
gmLI | numeric |
exLI | numeric |
Pulls | integer |
Games | integer |
WPA_LI | numeric |
Clutch | numeric |
FBall_pct | numeric |
FBv | numeric |
SL_pct | numeric |
SLv | numeric |
CT_pct | numeric |
CTv | numeric |
CB_pct | numeric |
CBv | numeric |
CH_pct | numeric |
CHv | numeric |
SF_pct | numeric |
SFv | numeric |
XX_pct | numeric |
wFB | numeric |
wSL | numeric |
wCT | numeric |
wCB | numeric |
wCH | numeric |
wSF | numeric |
wFB_C | numeric |
wSL_C | numeric |
wCT_C | numeric |
wCB_C | numeric |
wCH_C | numeric |
wSF_C | numeric |
O-Swing_pct | numeric |
Z-Swing_pct | numeric |
Swing_pct | numeric |
O-Contact_pct | numeric |
Z-Contact_pct | numeric |
Contact_pct | numeric |
Zone_pct | numeric |
F-Strike_pct | numeric |
SwStr_pct | numeric |
CStr_pct | numeric |
C+SwStr_pct | numeric |
HLD | integer |
SD | integer |
MD | integer |
ERA- | numeric |
FIP- | numeric |
xFIP- | numeric |
K_pct | numeric |
BB_pct | numeric |
K-BB_pct | numeric |
SIERA | numeric |
kwERA | numeric |
RS_9 | numeric |
E-F | numeric |
Pull | integer |
Cent | integer |
Oppo | integer |
Soft | integer |
Med | integer |
Hard | integer |
bipCount | integer |
Pull_pct | numeric |
Cent_pct | numeric |
Oppo_pct | numeric |
Soft_pct | numeric |
Med_pct | numeric |
Hard_pct | numeric |
K_9+ | numeric |
BB_9+ | numeric |
K_BB+ | numeric |
H_9+ | numeric |
HR_9+ | numeric |
AVG+ | numeric |
WHIP+ | numeric |
BABIP+ | numeric |
LOB_pct+ | numeric |
K_pct+ | numeric |
BB_pct+ | numeric |
LD_pct+ | numeric |
GB_pct+ | numeric |
FB_pct+ | numeric |
HRFB_pct+ | numeric |
Pull_pct+ | numeric |
Cent_pct+ | numeric |
Oppo_pct+ | numeric |
Soft_pct+ | numeric |
Med_pct+ | numeric |
Hard_pct+ | numeric |
rFTeamV | integer |
rBTeamV | integer |
rTV | integer |
pfx_FA_pct | numeric |
pfx_FT_pct | numeric |
pfx_FC_pct | numeric |
pfx_FS_pct | numeric |
pfx_SI_pct | numeric |
pfx_SL_pct | numeric |
pfx_CU_pct | numeric |
pfx_KC_pct | numeric |
pfx_CH_pct | numeric |
pfx_vFA | numeric |
pfx_vFT | numeric |
pfx_vFC | numeric |
pfx_vFS | numeric |
pfx_vSI | numeric |
pfx_vSL | numeric |
pfx_vCU | numeric |
pfx_vKC | numeric |
pfx_vCH | numeric |
pfx_FA-X | numeric |
pfx_FT-X | numeric |
pfx_FC-X | numeric |
pfx_FS-X | numeric |
pfx_SI-X | numeric |
pfx_SL-X | numeric |
pfx_CU-X | numeric |
pfx_KC-X | numeric |
pfx_CH-X | numeric |
pfx_FA-Z | numeric |
pfx_FT-Z | numeric |
pfx_FC-Z | numeric |
pfx_FS-Z | numeric |
pfx_SI-Z | numeric |
pfx_SL-Z | numeric |
pfx_CU-Z | numeric |
pfx_KC-Z | numeric |
pfx_CH-Z | numeric |
pfx_wFA | numeric |
pfx_wFT | numeric |
pfx_wFC | numeric |
pfx_wFS | numeric |
pfx_wSI | numeric |
pfx_wSL | numeric |
pfx_wCU | numeric |
pfx_wKC | numeric |
pfx_wCH | numeric |
pfx_wFA_C | numeric |
pfx_wFT_C | numeric |
pfx_wFC_C | numeric |
pfx_wFS_C | numeric |
pfx_wSI_C | numeric |
pfx_wSL_C | numeric |
pfx_wCU_C | numeric |
pfx_wKC_C | numeric |
pfx_wCH_C | numeric |
pfx_O-Swing_pct | numeric |
pfx_Z-Swing_pct | numeric |
pfx_Swing_pct | numeric |
pfx_O-Contact_pct | numeric |
pfx_Z-Contact_pct | numeric |
pfx_Contact_pct | numeric |
pfx_Zone_pct | numeric |
pfx_Pace | numeric |
pi_CH_pct | numeric |
pi_CU_pct | numeric |
pi_FA_pct | numeric |
pi_FC_pct | numeric |
pi_FS_pct | numeric |
pi_SI_pct | numeric |
pi_SL_pct | numeric |
pi_XX_pct | numeric |
pi_vCH | numeric |
pi_vCU | numeric |
pi_vFA | numeric |
pi_vFC | numeric |
pi_vFS | numeric |
pi_vSI | numeric |
pi_vSL | numeric |
pi_vXX | numeric |
pi_CH-X | numeric |
pi_CU-X | numeric |
pi_FA-X | numeric |
pi_FC-X | numeric |
pi_FS-X | numeric |
pi_SI-X | numeric |
pi_SL-X | numeric |
pi_XX-X | numeric |
pi_CH-Z | numeric |
pi_CU-Z | numeric |
pi_FA-Z | numeric |
pi_FC-Z | numeric |
pi_FS-Z | numeric |
pi_SI-Z | numeric |
pi_SL-Z | numeric |
pi_XX-Z | numeric |
pi_wCH | numeric |
pi_wCU | numeric |
pi_wFA | numeric |
pi_wFC | numeric |
pi_wFS | numeric |
pi_wSI | numeric |
pi_wSL | numeric |
pi_wXX | numeric |
pi_wCH_C | numeric |
pi_wCU_C | numeric |
pi_wFA_C | numeric |
pi_wFC_C | numeric |
pi_wFS_C | numeric |
pi_wSI_C | numeric |
pi_wSL_C | numeric |
pi_wXX_C | numeric |
pi_O-Swing_pct | numeric |
pi_Z-Swing_pct | numeric |
pi_Swing_pct | numeric |
pi_O-Contact_pct | numeric |
pi_Z-Contact_pct | numeric |
pi_Contact_pct | numeric |
pi_Zone_pct | numeric |
pi_Pace | numeric |
Events | integer |
EV | numeric |
LA | numeric |
Barrels | integer |
Barrel_pct | numeric |
maxEV | numeric |
HardHit | integer |
HardHit_pct | numeric |
Q | numeric |
TG | integer |
TIP | numeric |
team_name_abb | character |
teamid | integer |
pfx_EP_pct | numeric |
pfx_vEP | numeric |
pfx_EP-X | numeric |
pfx_EP-Z | numeric |
pfx_wEP | numeric |
pfx_wEP_C | numeric |
pi_SB_pct | numeric |
pi_vSB | numeric |
pi_SB-X | numeric |
pi_SB-Z | numeric |
pi_wSB | numeric |
pi_wSB_C | numeric |
pi_CS_pct | numeric |
pi_vCS | numeric |
pi_CS-X | numeric |
pi_CS-Z | numeric |
pi_wCS | numeric |
pi_wCS_C | numeric |
pi_KN_pct | numeric |
pi_vKN | numeric |
pi_KN-X | numeric |
pi_KN-Z | numeric |
pi_wKN | numeric |
pi_wKN_C | numeric |
KN_pct | numeric |
KNv | numeric |
wKN | numeric |
wKN_C | numeric |
pfx_KN_pct | numeric |
pfx_vKN | numeric |
pfx_KN-X | numeric |
pfx_KN-Z | numeric |
pfx_wKN | numeric |
pfx_wKN_C | numeric |
pfx_SC_pct | numeric |
pfx_vSC | numeric |
pfx_SC-X | numeric |
pfx_SC-Z | numeric |
pfx_wSC | numeric |
pfx_wSC_C | numeric |
pfx_FO_pct | numeric |
pfx_vFO | numeric |
pfx_FO-X | numeric |
pfx_FO-Z | numeric |
pfx_wFO | numeric |
pfx_wFO_C | numeric |
try(fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150))
try(fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150))
This function allows you to calculate FIP and related metrics for any given set of data, provided the right variables are in the data set. The function currently returns both FIP per inning pitched, wOBA against (based on batters faced), and wOBA against per instance of fair contact.
fip_plus(df)
fip_plus(df)
df |
A data frame of statistics that includes, at a minimum, the following columns: IP (innings pitched), BF (batters faced), uBB (unintentional walks), HBP (Hit By Pitch), x1B (singles), x2B (doubles), x3B (triples), HR (home runs), AB (at-bats), SH (sacrifice hits), SO (strike outs), and season. |
Returns a tibble with the following columns:
col_name | types |
bbref_id | character |
season | integer |
Name | character |
Age | numeric |
Level | character |
Team | character |
G | numeric |
GS | numeric |
W | numeric |
L | numeric |
SV | numeric |
IP | numeric |
H | numeric |
R | numeric |
ER | numeric |
uBB | numeric |
BB | numeric |
SO | numeric |
HR | numeric |
HBP | numeric |
ERA | numeric |
AB | numeric |
X1B | numeric |
X2B | numeric |
X3B | numeric |
IBB | numeric |
GDP | numeric |
SF | numeric |
SB | numeric |
CS | numeric |
PO | numeric |
BF | numeric |
Pit | numeric |
Str | numeric |
StL | numeric |
StS | numeric |
GB.FB | numeric |
LD | numeric |
PU | numeric |
WHIP | numeric |
BAbip | numeric |
SO9 | numeric |
SO.W | numeric |
SO_perc | numeric |
uBB_perc | numeric |
SO_uBB | numeric |
FIP | numeric |
wOBA_against | numeric |
wOBA_CON_against | numeric |
try({ df <- bref_daily_pitcher("2015-04-05", "2015-04-30") fip_plus(df) })
try({ df <- bref_daily_pitcher("2015-04-05", "2015-04-30") fip_plus(df) })
(legacy) Retrieve batting orders for a given MLB game
get_batting_orders(game_pk, type = "starting")
get_batting_orders(game_pk, type = "starting")
game_pk |
The unique game_pk identifier for the game |
type |
Whether to just return the starting lineup ('starting') or all batters that appeared ('all') |
Returns a tibble that includes probable starting pitchers and
the home plate umpire for the game_pk
requested
(legacy) Retrieve draft pick information by year
get_draft_mlb(year)
get_draft_mlb(year)
year |
The year for which to return data |
Returns a tibble with information for every draft pick in every round for the year requested
(legacy) Retrieve additional game information for major and minor league games
get_game_info_mlb(game_pk)
get_game_info_mlb(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tibble that includes supplemental information, such as weather, official scorer, attendance, etc., for the game_pk provided
(legacy) Download a data frame of supplemental data about MLB games since 2008.
get_game_info_sup_petti()
get_game_info_sup_petti()
Function returns a tibble with various columns, including:
game_pk
game_date
venue id
attendance
game temperature
wind speed
direction
start time
end time
(legacy) Get MLB Game Info by Date and Level
get_game_pks_mlb(date, level_ids = c(1))
get_game_pks_mlb(date, level_ids = c(1))
date |
The date for which you want to find game_pk values for MLB games |
level_ids |
A numeric vector with ids for each level where game_pks are desired. See below for a reference of level ids. |
Returns a tibble that includes game_pk values and additional information for games scheduled or played
(legacy) Get Play-By-Play Data for NCAA Baseball Games
(legacy) Get Play-By-Play Data for NCAA Baseball Games
get_ncaa_baseball_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... ) ncaa_baseball_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... )
get_ncaa_baseball_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... ) ncaa_baseball_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... )
game_info_url |
The url for the game's boxscore data. This can be found using the ncaa_schedule_info function. |
game_pbp_url |
The url for the game's play-by-play data. This can be found using the ncaa_schedule_info function. |
raw_html_to_disk |
Write raw html to disk (saves as |
raw_html_path |
Directory path to write raw html |
read_from_file |
Read from raw html on disk |
file |
File with full path to read raw html |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with play-by-play data for an individual game.
A data frame with play-by-play data for an individual game.
(legacy) Get NCAA Baseball Game Logs
get_ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
get_ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
player_id |
A player's unique id. Can be found using the get_ncaa_baseball_roster function. |
year |
The year of interest. |
type |
The kind of statistics you want to return. Current options are 'batting' or 'pitching'. |
span |
The span of time; can either be 'game' for game logs in a season, or 'career' which returns seasonal stats for a player's career. |
... |
Additional arguments passed to an underlying function like httr. |
A data frame containing player and school information as well as game by game statistics
game_info_url
(legacy) Retrieve lineups for a given NCAA game via its game_info_url
get_ncaa_lineups(game_info_url = NULL, ...)
get_ncaa_lineups(game_info_url = NULL, ...)
game_info_url |
The unique game info url |
... |
Additional arguments passed to an underlying function like httr. |
Returns a tibble of each school's starting lineup and starting pitcher
(legacy) Get Park Effects for NCAA Baseball Teams
get_ncaa_park_factor(team_id, years, type = "conference", ...)
get_ncaa_park_factor(team_id, years, type = "conference", ...)
team_id |
The team's unique NCAA id. |
years |
The season or seasons (i.e. use 2016 for the 2015-2016 season, etc., limited to just 2013-2023 seasons). |
type |
default is conference. the conference parameter adjusts for the conference the school plays in, the division parameter calculates based on the division the school plays in 1,2,or 3. Defaults to 'conference'. |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with the following fields: school, home_game, away_game, runs_scored_home, runs_allowed_home, run_scored_away, runs_allowed_away, base_pf (base park factor), home_game_adj (an adjustment for the percentage of home games played) final_pf (park factor after adjustments)
(legacy) Get Schedule and Results for NCAA Baseball Teams
get_ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
get_ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
team_id |
The team's unique NCAA id. |
year |
The season (i.e. use 2016 for the 2015-2016 season, etc.) |
pbp_links |
Logical parameter to run process for scraping play_by_play urls for each game |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with the following fields: date, opponent, result, score, innings (if more than regulation), and the url for the game itself.
(legacy) Acquire pitch-by-pitch data for Major and Minor League games
(legacy) Acquire pitch-by-pitch data for Major and Minor League games
get_pbp_mlb(game_pk) get_pbp_mlb(game_pk)
get_pbp_mlb(game_pk) get_pbp_mlb(game_pk)
game_pk |
The date for which you want to find game_pk values for MLB games |
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level.
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level.
(legacy) Retrieve probable starters for a given MLB game
get_probables_mlb(game_pk)
get_probables_mlb(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tibble that includes probable starting pitchers and
the home plate umpire for the game_pk
requested
(legacy) Get, Parse, and Format Retrosheet Event and Roster Files
get_retrosheet_data( path_to_directory = NULL, years_to_acquire = most_recent_mlb_season() - 1, sequence_years = FALSE )
get_retrosheet_data( path_to_directory = NULL, years_to_acquire = most_recent_mlb_season() - 1, sequence_years = FALSE )
path_to_directory |
(default: NULL) A file path that if set, either:
|
years_to_acquire |
(format: YYYY) The seasons to collect. Single, multiple, and
sequential years can be passed. If passing multiple years, enclose in a
vector (i.e. c(2017,2018)). Defaults to |
sequence_years |
(logical, default: FALSE): If the seasons passed in the years_to_acquire parameter should be sequenced so that the function returns all years including and between the vector passed, set the argument to TRUE. Defaults to FALSE. |
If path_to_directory
is not set (default), the process will return a named list
of tibbles: 'events' and 'rosters' for each season provided to years_to_acquire
If path_to_directory
is set, will also write two csv files to the unzipped directory: 1) a combined csv
of the event data for a given year and 2) a combined csv of each team's
roster for each year provided to years_to_acquire
(legacy) Download a data frame of all umpires and their MLBAM IDs for games since 2008
get_umpire_ids_petti()
get_umpire_ids_petti()
Function returns a tibble with the following columns:
id
position,
name
game_pk
game_date
This function allows you to create spray charts with ggplots given a data frame with batted ball location coordinates.
ggspraychart( data, x_value = "hc_x", y_value = "-hc_y", fill_value = NULL, fill_palette = NULL, fill_legend_title = NULL, density = FALSE, bin_size = 15, point_alpha = 0.75, point_size = 2, frame = NULL )
ggspraychart( data, x_value = "hc_x", y_value = "-hc_y", fill_value = NULL, fill_palette = NULL, fill_legend_title = NULL, density = FALSE, bin_size = 15, point_alpha = 0.75, point_size = 2, frame = NULL )
data |
A data frame that includes batted ball coordinates. Typically, this coordinates will come from the GameDay xml feed or downloads from baseballsavant.com |
x_value |
The x coordindate. Typically hc_x. |
y_value |
The y coordinate. Typically hc_y. You generally need the inverse or negative of the hc_y values, so it is recommended you calculate before plotting. |
fill_value |
The categorical variable that you want the geom_points to base the fill on. Pass as a string. If left blank, defaults to blue. |
fill_palette |
An object containing a customer palette to be used with ggplot2::scale_fill_manual. |
fill_legend_title |
A string containing a custom legend title to be used with ggplot2::scale_fill_manual. |
density |
Chooses between a 2d density plot or a point plot. Defaults to FALSE. |
bin_size |
Size of bins used when building a density plot. Defaults to 15. |
point_alpha |
Alpha value whenever geom_point is used. Defaults to .75. Recommend .3 for density plots. To remove points on density points set use point_alpha = 0. |
point_size |
Set the size of geom_point if used. |
frame |
Variable to use as the frame argument if using gganimate to create animated plots. For density plots be sure your variable is a factor. |
ggspraychart(df, x_value = "hc_x", y_value = "-hc_y", fill_value = "events")
A plot of the spraychart for the supplied dataset
Based on a series of heuristics, this function attempts to label Statcast data for which the launch angle and speed have been imputed.
label_statcast_imputed_data( statcast_df, impute_file = NULL, inverse_precision = 10000 )
label_statcast_imputed_data( statcast_df, impute_file = NULL, inverse_precision = 10000 )
statcast_df |
A dataframe containing Statcast batted ball data |
impute_file |
A CSV file giving the launch angle, launch speed,
|
inverse_precision |
inverse of how many digits to truncate the launch angle
and speed to for comparison. Default is |
A copy of the input dataframe with a new column imputed
appended. imputed
is 1 if launch angle and launch speed are likely imputed, 0 otherwise.
Returns a tibble 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 | logical |
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 |
ila | integer |
ils | integer |
imputed | numeric |
try({ statcast_df <- statcast_search("2017-05-01", "2017-05-02") sc_df <- label_statcast_imputed_data(statcast_df) mean(sc_df$imputed) })
try({ statcast_df <- statcast_search("2017-05-01", "2017-05-02") sc_df <- label_statcast_imputed_data(statcast_df) mean(sc_df$imputed) })
This function allows a user to generate linear weight values for events using Baseball Savant data. Output includes both linear weights above average and linear weights above outs for home runs, triples, doubles, singles, walks, hit by pitches, and outs.
linear_weights_savant(df, level = "plate appearance")
linear_weights_savant(df, level = "plate appearance")
df |
A data frame generated from Baseball Savant that has been run through
the |
level |
Whether to calculate linear weights the plate appearance or pitch level. Defaults to 'plate appearance'. |
Returns a tibble with the following columns:
col_name | types |
events | character |
linear_weights_above_average | numeric |
linear_weights_above_outs | numeric |
try({ df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') df <- run_expectancy_code(df, level = "plate appearances") linear_weights_savant(df, level = "plate appearance") })
try({ df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') df <- run_expectancy_code(df, level = "plate appearances") linear_weights_savant(df, level = "plate appearance") })
Download a data frame of supplemental data about MLB games since 2008.
load_game_info_sup()
load_game_info_sup()
Function returns a tibble with various columns, including:
game_pk
game_date
venue id
attendance
game temperature
wind speed
direction
start time
end time
try(load_game_info_sup())
try(load_game_info_sup())
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_ncaa_baseball_pbp( seasons = most_recent_ncaa_baseball_season(), ..., dbConnection = NULL, tablename = NULL )
load_ncaa_baseball_pbp( seasons = most_recent_ncaa_baseball_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NCAA college baseball seasons. (Min: 2022) |
... |
Additional arguments passed to an underlying function that writes the season data into a database. |
dbConnection |
A |
tablename |
The name of the schedule data table within the database |
Returns a tibble
try(load_ncaa_baseball_pbp(seasons = 2021))
try(load_ncaa_baseball_pbp(seasons = 2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_ncaa_baseball_schedule( seasons = most_recent_ncaa_baseball_season(), ..., dbConnection = NULL, tablename = NULL )
load_ncaa_baseball_schedule( seasons = most_recent_ncaa_baseball_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NCAA college baseball seasons. (Min: 2012) |
... |
Additional arguments passed to an underlying function that writes the season data into a database. |
dbConnection |
A |
tablename |
The name of the schedule data table within the database |
Returns a tibble
try(load_ncaa_baseball_schedule(seasons = 2022))
try(load_ncaa_baseball_schedule(seasons = 2022))
helper that loads multiple seasons of season IDs from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_ncaa_baseball_season_ids(..., dbConnection = NULL, tablename = NULL)
load_ncaa_baseball_season_ids(..., dbConnection = NULL, tablename = NULL)
... |
Additional arguments passed to an underlying function that writes the season data into a database. |
dbConnection |
A |
tablename |
The name of the data table within the database |
Returns a tibble
try(load_ncaa_baseball_season_ids())
try(load_ncaa_baseball_season_ids())
helper that loads multiple seasons of teams from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_ncaa_baseball_teams(..., dbConnection = NULL, tablename = NULL)
load_ncaa_baseball_teams(..., dbConnection = NULL, tablename = NULL)
... |
Additional arguments passed to an underlying function that writes the season data into a database. |
dbConnection |
A |
tablename |
The name of the data table within the database |
Returns a tibble
try(load_ncaa_baseball_teams())
try(load_ncaa_baseball_teams())
Download a data frame of all umpires and their mlbamids for games since 2008
load_umpire_ids()
load_umpire_ids()
Function returns a tibble with the following columns:
id
position
name
game_pk
game_date
try(load_umpire_ids())
try(load_umpire_ids())
fip_plus()
:Calculate FIP and related metrics for any set of data.
woba_plus()
Calculate wOBA and related metrics for any set of data.
team_consistency()
Calculate Team-level Consistency.
label_statcast_imputed_data()
Label Statcast data as imputed.
run_expectancy_code()
Generate run expectancy and related measures from Baseball Savant data.
linear_weights_savant()
Generate linear weight values for events using Baseball Savant data.
team_consistency(year=2015)
fips_plus(df)
woba_plus(df)
statcast_df <- scrape_statcast_savant("2017-05-01", "2017-05-02") sc_df <- label_statcast_imputed_data(statcast_df) mean(sc_df$imputed)
df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') run_expectancy_code(df, level = "plate appearances")
df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') df <- run_expectancy_code(df, level = "plate appearances") linear_weights_savant(df, level = "plate appearance")
(legacy) Scrape MiLB game logs for batters from FanGraphs
milb_batter_game_logs_fg(playerid, year)
milb_batter_game_logs_fg(playerid, year)
playerid |
The batter's minor league ID from FanGraphs. |
year |
The season for which game logs should be returned. |
Returns a tibble of Minor League batter game logs.
(legacy) Scrape MiLB game logs for pitchers from FanGraphs
milb_pitcher_game_logs_fg(playerid, year)
milb_pitcher_game_logs_fg(playerid, year)
playerid |
The pitcher's minor league ID from FanGraphs.com. |
year |
The season for which game logs should be returned. |
Returns a tibble of Minor League pitcher game logs.
mlb_batting_orders()
:Retrieve batting orders for a given MLB game.
mlb_draft()
:Retrieve draft pick information by year.
mlb_pbp()
:Acquire pitch-by-pitch data for Major and Minor League games.
mlb_game_info()
:Retrieve additional game information for major and minor league games.
mlb_game_pks()
:Get MLB Game Info by Date and Level.
mlb_schedule()
:Find game_pk values for professional baseball games (major and minor leagues).
mlb_probables()
:Retrieve probable starters for a given MLB game.
mlb_batting_orders(game_pk=566001)
mlb_draft(year= 2018)
mlb_pbp(game_pk = 575156)
mlb_game_info(game_pk = 566001)
mlb_game_pks("2019-04-29")
mlb_schedule(season = "2019")
mlb_probables(566001)
Find MLB All-Star Ballots
mlb_all_star_ballots(league_id = NULL, season = NULL)
mlb_all_star_ballots(league_id = NULL, season = NULL)
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Returns a tibble with the following columns:
col_name | types |
player_id | integer |
full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_state_province | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
is_player | logical |
is_verified | logical |
draft_year | integer |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
pronunciation | character |
name_matrilineal | character |
name_title | character |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
league_id | numeric |
season | numeric |
try(mlb_all_star_ballots(league_id = 103, season = 2021))
try(mlb_all_star_ballots(league_id = 103, season = 2021))
Find MLB All-Star Final Vote
mlb_all_star_final_vote(league_id = NULL, season = NULL)
mlb_all_star_final_vote(league_id = NULL, season = NULL)
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Returns a tibble with the following columns:
col_name | types |
player_id | integer |
full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_state_province | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
is_player | logical |
is_verified | logical |
draft_year | integer |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
pronunciation | character |
name_matrilineal | character |
name_title | character |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
league_id | numeric |
season | numeric |
try(mlb_all_star_final_vote(league_id = 103, season = 2021))
try(mlb_all_star_final_vote(league_id = 103, season = 2021))
Find MLB All-Star Write-ins
mlb_all_star_write_ins(league_id = NULL, season = NULL)
mlb_all_star_write_ins(league_id = NULL, season = NULL)
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Returns a tibble with the following columns:
col_name | types |
player_id | integer |
full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_state_province | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
is_player | logical |
is_verified | logical |
draft_year | integer |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
pronunciation | character |
name_matrilineal | character |
name_title | character |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
league_id | numeric |
season | numeric |
try(mlb_all_star_write_ins(league_id = 103, season = 2021))
try(mlb_all_star_write_ins(league_id = 103, season = 2021))
MLB Attendance
mlb_attendance( team_id = NULL, league_id = NULL, season = NULL, date = NULL, league_list_id = NULL )
mlb_attendance( team_id = NULL, league_id = NULL, season = NULL, date = NULL, league_list_id = NULL )
team_id |
Return attendance information for a particular team_id(s). |
league_id |
Return attendance information for a particular league_id(s). Format: '103,104' |
season |
Return attendance information for particular year(s). |
date |
Return attendance information on a particular date. Format: MM/DD/YYYY |
league_list_id |
Unique league list identifier to return a directory of attendance for a specific league list_id Valid values include:
|
Returns a tibble with the following columns
col_name | types |
openings_total | integer |
openings_total_away | integer |
openings_total_home | integer |
openings_total_lost | integer |
games_total | integer |
games_away_total | integer |
games_home_total | integer |
year | character |
attendance_average_away | integer |
attendance_average_home | integer |
attendance_average_ytd | integer |
attendance_high | integer |
attendance_high_date | character |
attendance_low | integer |
attendance_low_date | character |
attendance_opening_average | integer |
attendance_total | integer |
attendance_total_away | integer |
attendance_total_home | integer |
attendance_high_game_game_pk | integer |
attendance_high_game_link | character |
attendance_high_game_day_night | character |
attendance_high_game_content_link | character |
attendance_low_game_game_pk | integer |
attendance_low_game_link | character |
attendance_low_game_day_night | character |
attendance_low_game_content_link | character |
game_type_id | character |
game_type_description | character |
team_id | integer |
team_name | character |
team_link | character |
try(mlb_attendance(team_id = 109, season = 2021))
try(mlb_attendance(team_id = 109, season = 2021))
mlb_all_star_ballots()
:Find MLB All-Star Ballots.
mlb_all_star_final_vote()
:Find MLB All-Star Final Vote.
mlb_all_star_write_ins()
:Find MLB All-Star Write-ins.
mlb_awards()
:Find MLB Awards.
mlb_awards_recipient()
:Find MLB Award Recipients.
mlb_homerun_derby()
:Retrieve MLB Home Run Derby Data.
mlb_homerun_derby_bracket()
:Retrieve MLB Home Run Derby Bracket.
mlb_homerun_derby_players()
:Retrieve MLB Home Run Derby Players.
try(mlb_all_star_ballots(league_id = 103, season = 2021))
try(mlb_all_star_final_vote(league_id = 103, season = 2021))
try(mlb_all_star_write_ins(league_id = 103, season = 2021))
try(mlb_awards())
try(mlb_awards_recipient(award_id = 'MLBHOF', season = 2020))
try(mlb_homerun_derby(game_pk = 511101))
try(mlb_homerun_derby_bracket(game_pk = 511101))
try(mlb_homerun_derby_players(game_pk = 511101))
MLB Awards
mlb_awards()
mlb_awards()
Returns a tibble with the following columns
col_name | types |
award_id | character |
award_name | character |
award_description | character |
sort_order | integer |
notes | character |
sport_id | integer |
sport_link | character |
league_id | integer |
league_link | character |
try(mlb_awards())
try(mlb_awards())
MLB Award Recipients
mlb_awards_recipient( award_id = NULL, sport_id = NULL, league_id = NULL, season = NULL )
mlb_awards_recipient( award_id = NULL, sport_id = NULL, league_id = NULL, season = NULL )
award_id |
award_id to return a directory of players for a given award. |
sport_id |
sport_id to return a directory of players for a given aware in a specific sport. |
league_id |
league_id(s) to return a directory of players for a given award in a specific league. Format '103,104' |
season |
Year(s) to return a directory of players for a given award in a given season. |
Returns a tibble with the following columns
col_name | types |
award_id | character |
award_name | character |
date | character |
season | character |
votes | integer |
notes | character |
player_id | integer |
player_link | character |
player_name_first_last | character |
player_primary_position_code | character |
player_primary_position_name | character |
player_primary_position_type | character |
player_primary_position_abbreviation | character |
team_id | integer |
team_link | character |
try(mlb_awards_recipient(award_id = 'MLBHOF', season = 2020))
try(mlb_awards_recipient(award_id = 'MLBHOF', season = 2020))
MLB Baseball Stats
mlb_baseball_stats()
mlb_baseball_stats()
Returns a tibble with the following columns:
col_name | types |
stat_name | character |
stat_lookup_param | character |
is_counting | logical |
stat_label | character |
stat_group | character |
try(mlb_baseball_stats())
try(mlb_baseball_stats())
Retrieve batting orders for a given MLB game
mlb_batting_orders(game_pk, type = "starting")
mlb_batting_orders(game_pk, type = "starting")
game_pk |
The unique game_pk identifier for the game |
type |
Whether to just return the starting lineup ('starting') or all batters that appeared ('all') |
Returns a tibble that includes probable starting pitchers and
the home plate umpire for the game_pk
requested
col_name | types |
id | integer |
fullName | character |
abbreviation | character |
batting_order | character |
batting_position_num | character |
team | character |
teamName | character |
teamID | integer |
try(mlb_batting_orders(game_pk=566001))
try(mlb_batting_orders(game_pk=566001))
View all PCL conferences
mlb_conferences(conference_id = NULL, season = NULL)
mlb_conferences(conference_id = NULL, season = NULL)
conference_id |
Conference ID to return information for. |
season |
Year to return to return conference information for. |
Returns a tibble with the following columns
col_name | types |
conference_id | integer |
conference_name | character |
link | character |
conference_abbreviation | character |
has_wildcard | logical |
name_short | character |
league_id | integer |
league_link | character |
sport_id | integer |
sport_link | character |
try(mlb_conferences()) try(mlb_conferences(conference_id = 301, season = 2020))
try(mlb_conferences()) try(mlb_conferences(conference_id = 301, season = 2020))
MLB Divisions
mlb_divisions(division_id = NULL, league_id = NULL, sport_id = NULL)
mlb_divisions(division_id = NULL, league_id = NULL, sport_id = NULL)
division_id |
Return division(s) data for a specific division |
league_id |
Return division(s) data for all divisions in a specific league |
sport_id |
Return division(s) for all divisions in a specific sport. |
Returns a tibble with the following columns
col_name | types |
division_id | integer |
division_name | character |
season | character |
division_name_short | character |
division_link | character |
division_abbreviation | character |
has_wildcard | logical |
sort_order | integer |
num_playoff_teams | integer |
active | logical |
league_id | integer |
league_link | character |
sport_id | integer |
sport_link | character |
try(mlb_divisions(sport_id = 1))
try(mlb_divisions(sport_id = 1))
Retrieve draft pick information by year
mlb_draft(year)
mlb_draft(year)
year |
The year for which to return data |
Returns a tibble with information for every draft pick in every round for the year requested
col_name | types |
bis_player_id | integer |
pick_round | character |
pick_number | integer |
round_pick_number | integer |
rank | integer |
pick_value | character |
signing_bonus | character |
scouting_report | character |
blurb | character |
headshot_link | character |
is_drafted | logical |
is_pass | logical |
year | character |
home_city | character |
home_state | character |
home_country | character |
school_name | character |
school_school_class | character |
school_country | character |
school_state | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
person_primary_number | character |
person_birth_date | character |
person_current_age | integer |
person_birth_city | character |
person_birth_state_province | character |
person_birth_country | character |
person_height | character |
person_weight | integer |
person_active | logical |
person_use_name | character |
person_middle_name | character |
person_boxscore_name | character |
person_gender | character |
person_is_player | logical |
person_is_verified | logical |
person_draft_year | integer |
person_name_first_last | character |
person_name_slug | character |
person_first_last_name | character |
person_last_first_name | character |
person_last_init_name | character |
person_init_last_name | character |
person_full_fml_name | character |
person_full_lfm_name | character |
person_strike_zone_top | numeric |
person_strike_zone_bottom | numeric |
person_pronunciation | character |
person_name_title | character |
person_mlb_debut_date | character |
person_name_matrilineal | character |
person_primary_position_code | character |
person_primary_position_name | character |
person_primary_position_type | character |
person_primary_position_abbreviation | character |
person_bat_side_code | character |
person_bat_side_description | character |
person_pitch_hand_code | character |
person_pitch_hand_description | character |
team_id | integer |
team_name | character |
team_link | character |
team_all_star_status | character |
team_spring_league_id | integer |
team_spring_league_name | character |
team_spring_league_link | character |
team_spring_league_abbreviation | character |
draft_type_code | character |
draft_type_description | character |
try(mlb_draft(year = 2020))
try(mlb_draft(year = 2020))
Retrieve latest draft information by year
mlb_draft_latest(year)
mlb_draft_latest(year)
year |
The year for which to return data |
Returns a tibble with the latest draft information for the year requested:
col_name | types |
bis_player_id | integer |
pick_round | character |
pick_number | integer |
round_pick_number | integer |
rank | integer |
pick_value | character |
signing_bonus | character |
home_city | character |
home_state | character |
home_country | character |
scouting_report | character |
school_name | character |
school_school_class | character |
school_country | character |
school_state | character |
blurb | character |
headshot_link | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
person_primary_number | character |
person_birth_date | character |
person_current_age | integer |
person_birth_city | character |
person_birth_state_province | character |
person_birth_country | character |
person_height | character |
person_weight | integer |
person_active | logical |
person_primary_position_code | character |
person_primary_position_name | character |
person_primary_position_type | character |
person_primary_position_abbreviation | character |
person_use_name | character |
person_middle_name | character |
person_boxscore_name | character |
person_gender | character |
person_is_player | logical |
person_is_verified | logical |
person_draft_year | integer |
person_bat_side_code | character |
person_bat_side_description | character |
person_pitch_hand_code | character |
person_pitch_hand_description | character |
person_name_first_last | character |
person_name_slug | character |
person_first_last_name | character |
person_last_first_name | character |
person_last_init_name | character |
person_init_last_name | character |
person_full_fml_name | character |
person_full_lfm_name | character |
person_strike_zone_top | numeric |
person_strike_zone_bottom | numeric |
team_id | integer |
team_name | character |
team_link | character |
team_season | integer |
team_venue_id | integer |
team_venue_name | character |
team_venue_link | character |
team_spring_venue_id | integer |
team_spring_venue_link | character |
team_team_code | character |
team_file_code | character |
team_abbreviation | character |
team_team_name | character |
team_location_name | character |
team_first_year_of_play | character |
team_league_id | integer |
team_league_name | character |
team_league_link | character |
team_division_id | integer |
team_division_name | character |
team_division_link | character |
team_sport_id | integer |
team_sport_link | character |
team_sport_name | character |
team_short_name | character |
team_franchise_name | character |
team_club_name | character |
team_spring_league_id | integer |
team_spring_league_name | character |
team_spring_league_link | character |
team_spring_league_abbreviation | character |
team_all_star_status | character |
team_active | logical |
draft_type_code | character |
draft_type_description | character |
is_drafted | logical |
is_pass | logical |
year | character |
try(mlb_draft_latest(year = 2020))
try(mlb_draft_latest(year = 2020))
Retrieve draft prospect information by year
mlb_draft_prospects(year)
mlb_draft_prospects(year)
year |
The year for which to return data |
Returns a tibble with information for every draft prospect for the year requested:
col_name | types |
bis_player_id | integer |
pick_round | character |
pick_number | integer |
rank | integer |
scouting_report | character |
blurb | character |
headshot_link | character |
is_drafted | logical |
year | character |
home_city | character |
home_state | character |
home_country | character |
school_name | character |
school_school_class | character |
school_country | character |
school_state | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
person_birth_date | character |
person_current_age | integer |
person_birth_city | character |
person_birth_state_province | character |
person_birth_country | character |
person_height | character |
person_weight | integer |
person_active | logical |
person_use_name | character |
person_middle_name | character |
person_boxscore_name | character |
person_gender | character |
person_is_player | logical |
person_is_verified | logical |
person_draft_year | integer |
person_name_first_last | character |
person_name_slug | character |
person_first_last_name | character |
person_last_first_name | character |
person_last_init_name | character |
person_init_last_name | character |
person_full_fml_name | character |
person_full_lfm_name | character |
person_strike_zone_top | numeric |
person_strike_zone_bottom | numeric |
person_primary_number | character |
person_pronunciation | character |
person_name_title | character |
person_mlb_debut_date | character |
person_name_matrilineal | character |
person_nick_name | character |
person_death_date | character |
person_death_city | character |
person_death_state_province | character |
person_death_country | character |
person_primary_position_code | character |
person_primary_position_name | character |
person_primary_position_type | character |
person_primary_position_abbreviation | character |
person_bat_side_code | character |
person_bat_side_description | character |
person_pitch_hand_code | character |
person_pitch_hand_description | character |
team_id | integer |
team_name | character |
team_link | character |
team_season | integer |
team_team_code | character |
team_file_code | character |
team_abbreviation | character |
team_team_name | character |
team_location_name | character |
team_first_year_of_play | character |
team_short_name | character |
team_franchise_name | character |
team_club_name | character |
team_all_star_status | character |
team_active | logical |
team_venue_id | integer |
team_venue_name | character |
team_venue_link | character |
team_spring_venue_id | integer |
team_spring_venue_link | character |
team_league_id | integer |
team_league_name | character |
team_league_link | character |
team_division_id | integer |
team_division_name | character |
team_division_link | character |
team_sport_id | integer |
team_sport_link | character |
team_sport_name | character |
team_spring_league_id | integer |
team_spring_league_name | character |
team_spring_league_link | character |
team_spring_league_abbreviation | character |
draft_type_code | character |
draft_type_description | character |
try(mlb_draft_prospects(year = 2020))
try(mlb_draft_prospects(year = 2020))
MLB Event Types
mlb_event_types()
mlb_event_types()
Returns a tibble with the following columns
col_name | types |
plate_appearance | logical |
hit | logical |
event_code | character |
base_running_event | logical |
event_description | character |
try(mlb_event_types())
try(mlb_event_types())
MLB Fielder Detail Types
mlb_fielder_detail_types()
mlb_fielder_detail_types()
Returns a tibble with the following columns
col_name | types |
stat_name | character |
code | character |
names | character |
chance | logical |
error | logical |
try(mlb_fielder_detail_types())
try(mlb_fielder_detail_types())
Acquire time codes for Major and Minor League games
mlb_game_changes(updated_since, sport_id)
mlb_game_changes(updated_since, sport_id)
updated_since |
Updated since date time |
sport_id |
Return division(s) for all divisions in a specific sport. |
Returns a tibble that includes time codes from the game_pk requested
col_name | types |
date | character |
total_items | integer |
total_events | integer |
total_games | integer |
total_games_in_progress | integer |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
is_tie | logical |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
description | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
inning_break_length | integer |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_abstract_game_code | character |
teams_away_score | integer |
teams_away_is_winner | logical |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_home_score | integer |
teams_home_is_winner | logical |
teams_home_split_squad | logical |
teams_home_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
venue_id | integer |
venue_name | character |
venue_link | character |
content_link | character |
status_reason | character |
rescheduled_from | character |
rescheduled_from_date | character |
resumed_from | character |
resumed_from_date | character |
events | list |
try(mlb_game_changes(updated_since = "2021-08-10T19:08:24.000004Z", sport_id = 1))
try(mlb_game_changes(updated_since = "2021-08-10T19:08:24.000004Z", sport_id = 1))
Retrieve additional game content for major and minor league games
mlb_game_content(game_pk)
mlb_game_content(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tibble of game content data with the following columns:
col_name | types |
title | character |
epg_id | integer |
content_id | character |
media_id | character |
media_state | character |
media_feed_type | character |
media_feed_sub_type | character |
call_letters | character |
fox_auth_required | logical |
tbs_auth_required | logical |
espn_auth_required | logical |
fs1auth_required | logical |
mlbn_auth_required | logical |
free_game | logical |
type | character |
description | character |
rendition_name | character |
language | character |
try(mlb_game_content(game_pk = 566001))
try(mlb_game_content(game_pk = 566001))
Acquire game context metrics for Major and Minor League games
mlb_game_context_metrics(game_pk, timecode)
mlb_game_context_metrics(game_pk, timecode)
game_pk |
The game_pk for the game requested |
timecode |
The time code for the MLB game (format: MMDDYYYY_HHMMSS) |
Returns a tibble that includes time codes from the game_pk requested
col_name | types |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_abstract_game_code | character |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_score | integer |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_away_is_winner | logical |
teams_away_probable_pitcher_id | integer |
teams_away_probable_pitcher_full_name | character |
teams_away_probable_pitcher_link | character |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_score | integer |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
teams_home_is_winner | logical |
teams_home_probable_pitcher_id | integer |
teams_home_probable_pitcher_full_name | character |
teams_home_probable_pitcher_link | character |
teams_home_split_squad | logical |
teams_home_series_number | integer |
venue_id | integer |
venue_name | character |
venue_link | character |
link_1 | character |
is_tie | logical |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
inning_break_length | integer |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
game_id | character |
home_win_probability | numeric |
away_win_probability | numeric |
try(mlb_game_context_metrics(game_pk = 531060, timecode = "20180803_182458"))
try(mlb_game_context_metrics(game_pk = 531060, timecode = "20180803_182458"))
Retrieve additional game information for major and minor league games
mlb_game_info(game_pk)
mlb_game_info(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tibble that includes supplemental information, such as weather, official scorer, attendance, etc., for the game_pk provided
col_name | types |
game_date | character |
game_pk | numeric |
venue_name | character |
venue_id | integer |
temperature | character |
other_weather | character |
wind | character |
attendance | character |
start_time | character |
elapsed_time | character |
game_id | character |
game_type | character |
home_sport_code | character |
official_scorer | character |
date | character |
status_ind | character |
home_league_id | integer |
gameday_sw | character |
try(mlb_game_info(game_pk = 566001))
try(mlb_game_info(game_pk = 566001))
Retrieve game linescores for major and minor league games
mlb_game_linescore(game_pk)
mlb_game_linescore(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tibble with the following columns
col_name | types |
game_pk | numeric |
home_team_id | character |
home_team_name | character |
away_team_id | character |
away_team_name | character |
num | integer |
ordinal_num | character |
home_runs | integer |
home_hits | integer |
home_errors | integer |
home_left_on_base | integer |
away_runs | integer |
away_hits | integer |
away_errors | integer |
away_left_on_base | integer |
home_team_link | character |
home_team_season | character |
home_team_venue_id | character |
home_team_venue_name | character |
home_team_venue_link | character |
home_team_team_code | character |
home_team_file_code | character |
home_team_abbreviation | character |
home_team_team_name | character |
home_team_location_name | character |
home_team_first_year_of_play | character |
home_team_league_id | character |
home_team_league_name | character |
home_team_league_link | character |
home_team_division_id | character |
home_team_division_name | character |
home_team_division_link | character |
home_team_sport_id | character |
home_team_sport_link | character |
home_team_sport_name | character |
home_team_short_name | character |
home_team_record_games_played | character |
home_team_record_wild_card_games_back | character |
home_team_record_league_games_back | character |
home_team_record_spring_league_games_back | character |
home_team_record_sport_games_back | character |
home_team_record_division_games_back | character |
home_team_record_conference_games_back | character |
home_team_record_league_record_wins | character |
home_team_record_league_record_losses | character |
home_team_record_league_record_pct | character |
home_team_record_division_leader | character |
home_team_record_wins | character |
home_team_record_losses | character |
home_team_record_winning_percentage | character |
home_team_franchise_name | character |
home_team_club_name | character |
home_team_all_star_status | character |
home_team_active | character |
away_team_link | character |
away_team_season | character |
away_team_venue_id | character |
away_team_venue_name | character |
away_team_venue_link | character |
away_team_team_code | character |
away_team_file_code | character |
away_team_abbreviation | character |
away_team_team_name | character |
away_team_location_name | character |
away_team_first_year_of_play | character |
away_team_league_id | character |
away_team_league_name | character |
away_team_league_link | character |
away_team_division_id | character |
away_team_division_name | character |
away_team_division_link | character |
away_team_sport_id | character |
away_team_sport_link | character |
away_team_sport_name | character |
away_team_short_name | character |
away_team_record_games_played | character |
away_team_record_wild_card_games_back | character |
away_team_record_league_games_back | character |
away_team_record_spring_league_games_back | character |
away_team_record_sport_games_back | character |
away_team_record_division_games_back | character |
away_team_record_conference_games_back | character |
away_team_record_league_record_wins | character |
away_team_record_league_record_losses | character |
away_team_record_league_record_pct | character |
away_team_record_division_leader | character |
away_team_record_wins | character |
away_team_record_losses | character |
away_team_record_winning_percentage | character |
away_team_franchise_name | character |
away_team_club_name | character |
away_team_all_star_status | character |
away_team_active | character |
try(mlb_game_linescore(game_pk = 566001))
try(mlb_game_linescore(game_pk = 566001))
Retrieve game pace metrics for major and minor league
mlb_game_pace( season, league_ids = NULL, sport_ids = NULL, team_ids = NULL, game_type = NULL, venue_ids = NULL, org_type = NULL, start_date = NULL, end_date = NULL )
mlb_game_pace( season, league_ids = NULL, sport_ids = NULL, team_ids = NULL, game_type = NULL, venue_ids = NULL, org_type = NULL, start_date = NULL, end_date = NULL )
season |
Year for which to return information (Required). |
league_ids |
The league_id(s) for which to return information. |
sport_ids |
The sport_id(s) for which to return information. |
team_ids |
The team_id(s) for which to return information. |
game_type |
The game_type for which to return information. |
venue_ids |
Venue directorial information based venue_id. |
org_type |
pace of game metrics based on team ('T'), league ('L') or sport('S') |
start_date |
Date of first game for which you want data. Format must be in MM/DD/YYYY format. |
end_date |
Date of last game for which you want data. Format must be in MM/DD/YYYY format. |
Returns a tibble with the following columns
col_name | types |
hits_per9inn | numeric |
runs_per9inn | numeric |
pitches_per9inn | numeric |
plate_appearances_per9inn | numeric |
hits_per_game | numeric |
runs_per_game | numeric |
innings_played_per_game | numeric |
pitches_per_game | numeric |
pitchers_per_game | numeric |
plate_appearances_per_game | numeric |
total_game_time | character |
total_innings_played | integer |
total_hits | integer |
total_runs | integer |
total_plate_appearances | integer |
total_pitchers | integer |
total_pitches | integer |
total_games | integer |
total7inn_games | integer |
total9inn_games | integer |
total_extra_inn_games | integer |
time_per_game | character |
time_per_pitch | character |
time_per_hit | character |
time_per_run | character |
time_per_plate_appearance | character |
time_per9inn | character |
time_per77plate_appearances | character |
total_extra_inn_time | character |
time_per7inn_game | character |
time_per7inn_game_without_extra_inn | character |
total7inn_games_scheduled | integer |
total7inn_games_without_extra_inn | integer |
total9inn_games_completed_early | integer |
total9inn_games_without_extra_inn | integer |
total9inn_games_scheduled | integer |
hits_per_run | numeric |
pitches_per_pitcher | numeric |
season | character |
sport_id | integer |
sport_code | character |
sport_link | character |
pr_portal_calculated_fields_total7inn_games | integer |
pr_portal_calculated_fields_total9inn_games | integer |
pr_portal_calculated_fields_total_extra_inn_games | integer |
pr_portal_calculated_fields_time_per7inn_game | character |
pr_portal_calculated_fields_time_per9inn_game | character |
pr_portal_calculated_fields_time_per_extra_inn_game | character |
try(mlb_game_pace(season = 2021, start_date = "09/14/2021", end_date = "09/16/2021"))
try(mlb_game_pace(season = 2021, start_date = "09/14/2021", end_date = "09/16/2021"))
Find game_pk values for professional baseball games (major and minor leagues) via the MLB api https://www.mlb.com/
mlb_game_pks(date, level_ids = c(1))
mlb_game_pks(date, level_ids = c(1))
date |
The date for which you want to find game_pk values for MLB games |
level_ids |
A numeric vector with ids for each level where game_pks are desired. See below for a reference of level ids. |
Level IDs:
The following IDs can be passed to the level_ids argument:
1 = MLB 11 = Triple-A 12 = Doubl-A 13 = Class A Advanced 14 = Class A 15 = Class A Short Season 5442 = Rookie Advanced 16 = Rookie 17 = Winter League
Returns a tibble that includes game_pk values and additional information for games scheduled or played with the following columns:
col_name | types |
game_pk | integer |
link | character |
gameType | character |
season | character |
gameDate | character |
officialDate | character |
isTie | logical |
gameNumber | integer |
publicFacing | logical |
doubleHeader | character |
gamedayType | character |
tiebreaker | character |
calendarEventID | character |
seasonDisplay | character |
dayNight | character |
scheduledInnings | integer |
reverseHomeAwayStatus | logical |
inningBreakLength | integer |
gamesInSeries | integer |
seriesGameNumber | integer |
seriesDescription | character |
recordSource | character |
ifNecessary | character |
ifNecessaryDescription | character |
status.abstractGameState | character |
status.codedGameState | character |
status.detailedState | character |
status.statusCode | character |
status.startTimeTBD | logical |
status.abstractGameCode | character |
teams.away.score | integer |
teams.away.isWinner | logical |
teams.away.splitSquad | logical |
teams.away.seriesNumber | integer |
teams.away.leagueRecord.wins | integer |
teams.away.leagueRecord.losses | integer |
teams.away.leagueRecord.pct | character |
teams.away.team.id | integer |
teams.away.team.name | character |
teams.away.team.link | character |
teams.home.score | integer |
teams.home.isWinner | logical |
teams.home.splitSquad | logical |
teams.home.seriesNumber | integer |
teams.home.leagueRecord.wins | integer |
teams.home.leagueRecord.losses | integer |
teams.home.leagueRecord.pct | character |
teams.home.team.id | integer |
teams.home.team.name | character |
teams.home.team.link | character |
venue.id | integer |
venue.name | character |
venue.link | character |
content.link | character |
try(mlb_game_pks("2019-04-29"))
try(mlb_game_pks("2019-04-29"))
MLB Game Status Codes
mlb_game_status_codes()
mlb_game_status_codes()
Returns a tibble with the following columns
col_name | types |
abstract_game_state | character |
coded_game_state | character |
detailed_state | character |
status_code | character |
reason | character |
abstract_game_code | character |
try(mlb_game_status_codes())
try(mlb_game_status_codes())
Acquire time codes for Major and Minor League games
mlb_game_timecodes(game_pk)
mlb_game_timecodes(game_pk)
game_pk |
The game_pk for the game requested |
Returns a tibble that includes time codes from the game_pk requested
col_name | types |
timecodes (MMDDYYYY_HHMMSS) | numeric |
try(mlb_game_timecodes(game_pk = 632970))
try(mlb_game_timecodes(game_pk = 632970))
MLB Game Types
mlb_game_types()
mlb_game_types()
Returns a tibble with the following columns
col_name | types |
game_type_id | character |
game_type_description | character |
try(mlb_game_types())
try(mlb_game_types())
Acquire win probability for Major and Minor League games
mlb_game_wp(game_pk, timecode = NULL)
mlb_game_wp(game_pk, timecode = NULL)
game_pk |
The game_pk for the game requested |
timecode |
The time code for the MLB game (format: MMDDYYYY_HHMMSS) |
Returns a tibble that includes time codes from the game_pk requested
col_name | types |
home_team_win_probability | numeric |
away_team_win_probability | numeric |
home_team_win_probability_added | numeric |
at_bat_index | integer |
leverage_index | numeric |
try(mlb_game_wp(game_pk = 531060))
try(mlb_game_wp(game_pk = 531060))
Acquire high/low stats for Major and Minor Leagues
mlb_high_low_stats( org_type, season, sort_stat, team_ids = NULL, league_ids = NULL, sport_ids = NULL, game_type = NULL, stat_group = NULL, limit = NULL )
mlb_high_low_stats( org_type, season, sort_stat, team_ids = NULL, league_ids = NULL, sport_ids = NULL, game_type = NULL, stat_group = NULL, limit = NULL )
org_type |
The organization type for return information (Required). Valid values include:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
season |
The season for which you want to return information (Required). |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sort_stat |
The stat to sort the return (Required). Valid values can be found from 'stat_lookup_param' below
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
team_ids |
The team_id(s) for which to return information. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
league_ids |
The league_id(s) for which to return information. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sport_ids |
The sport_id(s) for which to return information. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
game_type |
The game_type for which to return information. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stat_group |
Stat group for which to return information. Valid values include:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
limit |
Number of records as the limit of the return. |
Returns a tibble with the following columns
col_name | types |
total_splits | integer |
season | integer |
date | character |
is_home | logical |
rank | integer |
game_innings | integer |
stat_at_bats | integer |
team_id | integer |
team_name | character |
team_link | character |
opponent_id | integer |
opponent_name | character |
opponent_link | character |
game_pk | integer |
game_link | character |
game_number | integer |
game_content_link | character |
home_team_id | integer |
home_team_name | character |
home_team_link | character |
away_team_id | integer |
away_team_name | character |
away_team_link | character |
combined_stats | logical |
group_display_name | character |
game_type_id | character |
game_type_description | character |
sort_stat_name | character |
sort_stat_lookup_param | character |
sort_stat_is_counting | logical |
sort_stat_label | character |
try(mlb_high_low_stats(org_type = 'Team', season = 2020, sort_stat = 'atBats'))
try(mlb_high_low_stats(org_type = 'Team', season = 2020, sort_stat = 'atBats'))
MLB Stat High/Low Types
mlb_high_low_types()
mlb_high_low_types()
Returns a tibble with the following columns
col_name | types |
stat_name | character |
stat_lookup_param | character |
is_counting | logical |
stat_label | character |
stat_groups | list |
org_types | list |
high_low_types | list |
try(mlb_high_low_types())
try(mlb_high_low_types())
MLB Hit Trajectories
mlb_hit_trajectories()
mlb_hit_trajectories()
Returns a tibble with the following columns
col_name | types |
hit_trajectory_code | character |
hit_trajectory_description | character |
try(mlb_hit_trajectories())
try(mlb_hit_trajectories())
Retrieve Homerun Derby data
mlb_homerun_derby(game_pk)
mlb_homerun_derby(game_pk)
game_pk |
The game_pk for which you want to return data |
Returns a tibble with the following columns
col_name | types |
game_pk | integer |
event_name | character |
event_date | character |
event_type_code | character |
event_type_name | character |
venue_id | integer |
venue_name | character |
round | integer |
num_batters | integer |
batter | character |
batter_id | integer |
batter_link | character |
top_seed_started | logical |
top_seed_complete | logical |
top_seed_winner | logical |
bonus_time | logical |
home_run | logical |
tie_breaker | logical |
is_home_run | logical |
time_remaining | character |
is_bonus_time | logical |
is_tie_breaker | logical |
hit_data_launch_speed | integer |
hit_data_launch_angle | integer |
hit_data_total_distance | integer |
hit_data_coordinates_coord_x | numeric |
hit_data_coordinates_coord_y | numeric |
hit_data_coordinates_landing_pos_x | numeric |
hit_data_coordinates_landing_pos_y | numeric |
hit_data_trajectory_data_trajectory_polynomial_x | list |
hit_data_trajectory_data_trajectory_polynomial_y | list |
hit_data_trajectory_data_trajectory_polynomial_z | list |
hit_data_trajectory_data_valid_time_interval | list |
top_seed_seed | integer |
top_seed_is_winner | logical |
top_seed_is_complete | logical |
top_seed_is_started | logical |
top_seed_num_home_runs | integer |
top_seed_player_id | integer |
top_seed_player_full_name | character |
top_seed_player_link | character |
top_seed_top_derby_hit_data_launch_speed | integer |
top_seed_top_derby_hit_data_total_distance | integer |
bottom_seed_started | logical |
bottom_seed_complete | logical |
bottom_seed_winner | logical |
bottom_seed_seed | integer |
bottom_seed_is_winner | logical |
bottom_seed_is_complete | logical |
bottom_seed_is_started | logical |
bottom_seed_num_home_runs | integer |
bottom_seed_player_id | integer |
bottom_seed_player_full_name | character |
bottom_seed_player_link | character |
bottom_seed_top_derby_hit_data_launch_speed | integer |
bottom_seed_top_derby_hit_data_total_distance | integer |
venue_link | character |
is_multi_day | logical |
is_primary_calendar | logical |
file_code | character |
event_number | integer |
public_facing | logical |
try(mlb_homerun_derby(game_pk = 511101))
try(mlb_homerun_derby(game_pk = 511101))
Retrieve Homerun Derby Bracket
mlb_homerun_derby_bracket(game_pk)
mlb_homerun_derby_bracket(game_pk)
game_pk |
The game_pk for which you want to return data |
Returns a tibble with the following columns
col_name | types |
game_pk | integer |
event_name | character |
event_type_code | character |
event_type_name | character |
event_date | character |
venue_id | integer |
venue_name | character |
venue_link | character |
is_multi_day | logical |
is_primary_calendar | logical |
file_code | character |
event_number | integer |
public_facing | logical |
round | integer |
num_batters | integer |
top_seed_complete | logical |
top_seed_started | logical |
top_seed_winner | logical |
top_seed_seed | integer |
top_seed_is_winner | logical |
top_seed_is_complete | logical |
top_seed_is_started | logical |
top_seed_num_home_runs | integer |
top_seed_player_id | integer |
top_seed_player_full_name | character |
top_seed_player_link | character |
top_seed_top_derby_hit_data_launch_speed | integer |
top_seed_top_derby_hit_data_total_distance | integer |
bottom_seed_complete | logical |
bottom_seed_started | logical |
bottom_seed_winner | logical |
bottom_seed_seed | integer |
bottom_seed_is_winner | logical |
bottom_seed_is_complete | logical |
bottom_seed_is_started | logical |
bottom_seed_num_home_runs | integer |
bottom_seed_player_id | integer |
bottom_seed_player_full_name | character |
bottom_seed_player_link | character |
bottom_seed_top_derby_hit_data_launch_speed | integer |
bottom_seed_top_derby_hit_data_total_distance | integer |
try(mlb_homerun_derby_bracket(game_pk = 511101))
try(mlb_homerun_derby_bracket(game_pk = 511101))
Retrieve Homerun Derby Players
mlb_homerun_derby_players(game_pk)
mlb_homerun_derby_players(game_pk)
game_pk |
The game_pk for which you want to return data |
Returns a tibble with the following columns
col_name | types |
game_pk | integer |
event_name | character |
event_date | character |
event_type_code | character |
event_type_name | character |
venue_id | integer |
venue_name | character |
player_id | integer |
player_full_name | character |
player_link | character |
player_first_name | character |
player_last_name | character |
player_primary_number | character |
player_birth_date | character |
player_current_age | integer |
player_birth_city | character |
player_birth_state_province | character |
player_birth_country | character |
player_height | character |
player_weight | integer |
player_active | logical |
player_use_name | character |
player_middle_name | character |
player_boxscore_name | character |
player_nick_name | character |
player_gender | character |
player_is_player | logical |
player_is_verified | logical |
player_draft_year | integer |
player_pronunciation | character |
player_mlb_debut_date | character |
player_name_first_last | character |
player_name_slug | character |
player_first_last_name | character |
player_last_first_name | character |
player_last_init_name | character |
player_init_last_name | character |
player_full_fml_name | character |
player_full_lfm_name | character |
player_strike_zone_top | numeric |
player_strike_zone_bottom | numeric |
player_name_matrilineal | character |
player_current_team_id | integer |
player_current_team_name | character |
player_current_team_link | character |
player_current_team_season | integer |
player_current_team_team_code | character |
player_current_team_file_code | character |
player_current_team_abbreviation | character |
player_current_team_team_name | character |
player_current_team_location_name | character |
player_current_team_first_year_of_play | character |
player_current_team_short_name | character |
player_current_team_franchise_name | character |
player_current_team_club_name | character |
player_current_team_all_star_status | character |
player_current_team_active | logical |
player_current_team_parent_org_name | character |
player_current_team_parent_org_id | integer |
player_current_team_venue_id | integer |
player_current_team_venue_name | character |
player_current_team_venue_link | character |
player_current_team_spring_venue_id | integer |
player_current_team_spring_venue_link | character |
player_current_team_league_id | integer |
player_current_team_league_name | character |
player_current_team_league_link | character |
player_current_team_division_id | integer |
player_current_team_division_name | character |
player_current_team_division_link | character |
player_current_team_sport_id | integer |
player_current_team_sport_link | character |
player_current_team_sport_name | character |
player_current_team_spring_league_id | integer |
player_current_team_spring_league_name | character |
player_current_team_spring_league_link | character |
player_current_team_spring_league_abbreviation | character |
player_primary_position_code | character |
player_primary_position_name | character |
player_primary_position_type | character |
player_primary_position_abbreviation | character |
player_bat_side_code | character |
player_bat_side_description | character |
player_pitch_hand_code | character |
player_pitch_hand_description | character |
venue_link | character |
is_multi_day | logical |
is_primary_calendar | logical |
file_code | character |
event_number | integer |
public_facing | logical |
try(mlb_homerun_derby_players(game_pk = 511101))
try(mlb_homerun_derby_players(game_pk = 511101))
MLB Job Types
mlb_job_types()
mlb_job_types()
Returns a tibble with the following columns
col_name | types |
job_code | character |
job | character |
sort_order | integer |
try(mlb_job_types())
try(mlb_job_types())
MLB Jobs
mlb_jobs(job_type = "UMPR", sport_id = NULL, date = NULL)
mlb_jobs(job_type = "UMPR", sport_id = NULL, date = NULL)
job_type |
Return information for a given job_type. See |
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_code | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_jobs(job_type='UMPR'))
try(mlb_jobs(job_type='UMPR'))
MLB Jobs Datacasters
mlb_jobs_datacasters(sport_id = NULL, date = NULL)
mlb_jobs_datacasters(sport_id = NULL, date = NULL)
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_code | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_jobs_datacasters(sport_id=1))
try(mlb_jobs_datacasters(sport_id=1))
MLB Jobs Official Scorers
mlb_jobs_official_scorers(sport_id = NULL, date = NULL)
mlb_jobs_official_scorers(sport_id = NULL, date = NULL)
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_code | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_jobs_official_scorers(sport_id=1))
try(mlb_jobs_official_scorers(sport_id=1))
MLB Jobs Umpires
mlb_jobs_umpires(sport_id = NULL, date = NULL)
mlb_jobs_umpires(sport_id = NULL, date = NULL)
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_code | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_jobs_umpires(sport_id=1))
try(mlb_jobs_umpires(sport_id=1))
MLB API Language Options
mlb_languages()
mlb_languages()
Returns a tibble with the following columns
col_name | types |
language_name | character |
language_code | character |
locale | character |
try(mlb_languages())
try(mlb_languages())
MLB Leagues
mlb_league(seasons = NULL, sport_id = NULL, league_id = NULL)
mlb_league(seasons = NULL, sport_id = NULL, league_id = NULL)
seasons |
Year(s) to return to return league information for. |
sport_id |
The sport_id to return league information for. |
league_id |
The league_id(s) to return league information for. |
Returns a tibble with the following columns
col_name | types |
leader_type | character |
try(mlb_league(seasons = 2021, sport_id = 1))
try(mlb_league(seasons = 2021, sport_id = 1))
MLB League Leader Types
mlb_league_leader_types()
mlb_league_leader_types()
Returns a tibble with the following columns
col_name | types |
leader_type | character |
try(mlb_league_leader_types())
try(mlb_league_leader_types())
MLB Logical Events
mlb_logical_events()
mlb_logical_events()
Returns a tibble with the following columns
col_name | types |
event_code | character |
try(mlb_logical_events())
try(mlb_logical_events())
MLB Metrics
mlb_metrics()
mlb_metrics()
Returns a tibble with the following columns
col_name | types |
metric_name | character |
metric_id | integer |
stat_group | character |
metric_unit | character |
try(mlb_metrics())
try(mlb_metrics())
Acquire pitch-by-pitch data for Major and Minor League games
mlb_pbp(game_pk)
mlb_pbp(game_pk)
game_pk |
The date for which you want to find game_pk values for MLB games |
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level.
Some data will vary depending on the park and the league level, as most sensor data is not available in minor league parks via this API. Note that the column names have mostly been left as-is and there are likely duplicate columns in terms of the information they provide. I plan to clean the output up down the road, but for now I am leaving the majority as-is.
Both major and minor league pitch-by-pitch data can be pulled with this function.
col_name | types |
game_pk | numeric |
game_date | character |
index | integer |
startTime | character |
endTime | character |
isPitch | logical |
type | character |
playId | character |
pitchNumber | integer |
details.description | character |
details.event | character |
details.awayScore | integer |
details.homeScore | integer |
details.isScoringPlay | logical |
details.hasReview | logical |
details.code | character |
details.ballColor | character |
details.isInPlay | logical |
details.isStrike | logical |
details.isBall | logical |
details.call.code | character |
details.call.description | character |
count.balls.start | integer |
count.strikes.start | integer |
count.outs.start | integer |
player.id | integer |
player.link | character |
pitchData.strikeZoneTop | numeric |
pitchData.strikeZoneBottom | numeric |
details.fromCatcher | logical |
pitchData.coordinates.x | numeric |
pitchData.coordinates.y | numeric |
hitData.trajectory | character |
hitData.hardness | character |
hitData.location | character |
hitData.coordinates.coordX | numeric |
hitData.coordinates.coordY | numeric |
actionPlayId | character |
details.eventType | character |
details.runnerGoing | logical |
position.code | character |
position.name | character |
position.type | character |
position.abbreviation | character |
battingOrder | character |
atBatIndex | character |
result.type | character |
result.event | character |
result.eventType | character |
result.description | character |
result.rbi | integer |
result.awayScore | integer |
result.homeScore | integer |
about.atBatIndex | integer |
about.halfInning | character |
about.inning | integer |
about.startTime | character |
about.endTime | character |
about.isComplete | logical |
about.isScoringPlay | logical |
about.hasReview | logical |
about.hasOut | logical |
about.captivatingIndex | integer |
count.balls.end | integer |
count.strikes.end | integer |
count.outs.end | integer |
matchup.batter.id | integer |
matchup.batter.fullName | character |
matchup.batter.link | character |
matchup.batSide.code | character |
matchup.batSide.description | character |
matchup.pitcher.id | integer |
matchup.pitcher.fullName | character |
matchup.pitcher.link | character |
matchup.pitchHand.code | character |
matchup.pitchHand.description | character |
matchup.splits.batter | character |
matchup.splits.pitcher | character |
matchup.splits.menOnBase | character |
batted.ball.result | factor |
home_team | character |
home_level_id | integer |
home_level_name | character |
home_parentOrg_id | integer |
home_parentOrg_name | character |
home_league_id | integer |
home_league_name | character |
away_team | character |
away_level_id | integer |
away_level_name | character |
away_parentOrg_id | integer |
away_parentOrg_name | character |
away_league_id | integer |
away_league_name | character |
batting_team | character |
fielding_team | character |
last.pitch.of.ab | character |
pfxId | character |
details.trailColor | character |
details.type.code | character |
details.type.description | character |
pitchData.startSpeed | numeric |
pitchData.endSpeed | numeric |
pitchData.zone | integer |
pitchData.typeConfidence | numeric |
pitchData.plateTime | numeric |
pitchData.extension | numeric |
pitchData.coordinates.aY | numeric |
pitchData.coordinates.aZ | numeric |
pitchData.coordinates.pfxX | numeric |
pitchData.coordinates.pfxZ | numeric |
pitchData.coordinates.pX | numeric |
pitchData.coordinates.pZ | numeric |
pitchData.coordinates.vX0 | numeric |
pitchData.coordinates.vY0 | numeric |
pitchData.coordinates.vZ0 | numeric |
pitchData.coordinates.x0 | numeric |
pitchData.coordinates.y0 | numeric |
pitchData.coordinates.z0 | numeric |
pitchData.coordinates.aX | numeric |
pitchData.breaks.breakAngle | numeric |
pitchData.breaks.breakLength | numeric |
pitchData.breaks.breakY | numeric |
pitchData.breaks.spinRate | integer |
pitchData.breaks.spinDirection | integer |
hitData.launchSpeed | numeric |
hitData.launchAngle | numeric |
hitData.totalDistance | numeric |
injuryType | character |
umpire.id | integer |
umpire.link | character |
isBaseRunningPlay | logical |
isSubstitution | logical |
about.isTopInning | logical |
matchup.postOnFirst.id | integer |
matchup.postOnFirst.fullName | character |
matchup.postOnFirst.link | character |
matchup.postOnSecond.id | integer |
matchup.postOnSecond.fullName | character |
matchup.postOnSecond.link | character |
matchup.postOnThird.id | integer |
matchup.postOnThird.fullName | character |
matchup.postOnThird.link | character |
try(mlb_pbp(game_pk = 632970))
try(mlb_pbp(game_pk = 632970))
Acquire pitch-by-pitch data between two timecodes for Major and Minor League games
mlb_pbp_diff(game_pk, start_timecode, end_timecode)
mlb_pbp_diff(game_pk, start_timecode, end_timecode)
game_pk |
The date for which you want to find game_pk values for MLB games |
start_timecode |
The start time code for the MLB game (format: MMDDYYYY_HHMMSS) |
end_timecode |
The end time code for the MLB game (format: MMDDYYYY_HHMMSS) |
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level between the start_timecode and end_timecode
col_name | types |
game_pk | numeric |
game_date | character |
index | integer |
startTime | character |
endTime | character |
isPitch | logical |
type | character |
playId | character |
pitchNumber | integer |
details.description | character |
details.event | character |
details.awayScore | integer |
details.homeScore | integer |
details.isScoringPlay | logical |
details.hasReview | logical |
details.code | character |
details.ballColor | character |
details.isInPlay | logical |
details.isStrike | logical |
details.isBall | logical |
details.call.code | character |
details.call.description | character |
count.balls.start | integer |
count.strikes.start | integer |
count.outs.start | integer |
player.id | integer |
player.link | character |
pitchData.strikeZoneTop | numeric |
pitchData.strikeZoneBottom | numeric |
details.fromCatcher | logical |
pitchData.coordinates.x | numeric |
pitchData.coordinates.y | numeric |
hitData.trajectory | character |
hitData.hardness | character |
hitData.location | character |
hitData.coordinates.coordX | numeric |
hitData.coordinates.coordY | numeric |
actionPlayId | character |
details.eventType | character |
details.runnerGoing | logical |
position.code | character |
position.name | character |
position.type | character |
position.abbreviation | character |
battingOrder | character |
atBatIndex | character |
result.type | character |
result.event | character |
result.eventType | character |
result.description | character |
result.rbi | integer |
result.awayScore | integer |
result.homeScore | integer |
about.atBatIndex | integer |
about.halfInning | character |
about.inning | integer |
about.startTime | character |
about.endTime | character |
about.isComplete | logical |
about.isScoringPlay | logical |
about.hasReview | logical |
about.hasOut | logical |
about.captivatingIndex | integer |
count.balls.end | integer |
count.strikes.end | integer |
count.outs.end | integer |
matchup.batter.id | integer |
matchup.batter.fullName | character |
matchup.batter.link | character |
matchup.batSide.code | character |
matchup.batSide.description | character |
matchup.pitcher.id | integer |
matchup.pitcher.fullName | character |
matchup.pitcher.link | character |
matchup.pitchHand.code | character |
matchup.pitchHand.description | character |
matchup.splits.batter | character |
matchup.splits.pitcher | character |
matchup.splits.menOnBase | character |
batted.ball.result | factor |
home_team | character |
home_level_id | integer |
home_level_name | character |
home_parentOrg_id | integer |
home_parentOrg_name | character |
home_league_id | integer |
home_league_name | character |
away_team | character |
away_level_id | integer |
away_level_name | character |
away_parentOrg_id | integer |
away_parentOrg_name | character |
away_league_id | integer |
away_league_name | character |
batting_team | character |
fielding_team | character |
last.pitch.of.ab | character |
pfxId | character |
details.trailColor | character |
details.type.code | character |
details.type.description | character |
pitchData.startSpeed | numeric |
pitchData.endSpeed | numeric |
pitchData.zone | integer |
pitchData.typeConfidence | numeric |
pitchData.plateTime | numeric |
pitchData.extension | numeric |
pitchData.coordinates.aY | numeric |
pitchData.coordinates.aZ | numeric |
pitchData.coordinates.pfxX | numeric |
pitchData.coordinates.pfxZ | numeric |
pitchData.coordinates.pX | numeric |
pitchData.coordinates.pZ | numeric |
pitchData.coordinates.vX0 | numeric |
pitchData.coordinates.vY0 | numeric |
pitchData.coordinates.vZ0 | numeric |
pitchData.coordinates.x0 | numeric |
pitchData.coordinates.y0 | numeric |
pitchData.coordinates.z0 | numeric |
pitchData.coordinates.aX | numeric |
pitchData.breaks.breakAngle | numeric |
pitchData.breaks.breakLength | numeric |
pitchData.breaks.breakY | numeric |
pitchData.breaks.spinRate | integer |
pitchData.breaks.spinDirection | integer |
hitData.launchSpeed | numeric |
hitData.launchAngle | numeric |
hitData.totalDistance | numeric |
injuryType | character |
umpire.id | integer |
umpire.link | character |
about.isTopInning | logical |
matchup.postOnFirst.id | integer |
matchup.postOnFirst.fullName | character |
matchup.postOnFirst.link | character |
try(mlb_pbp_diff(game_pk = 632970, start_timecode = "20210808_231704", end_timecode = "20210808_233711"))
try(mlb_pbp_diff(game_pk = 632970, start_timecode = "20210808_231704", end_timecode = "20210808_233711"))
Find Biographical Information for MLB Players
mlb_people(person_ids = NULL)
mlb_people(person_ids = NULL)
person_ids |
MLBAMIDs for players of interest. Multiple IDs should be provided in a vector separated by a comma. |
Returns a tibble with the following columns:
col_name | types |
id | integer |
full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_state_province | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
is_player | logical |
is_verified | logical |
draft_year | integer |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
pronunciation | character |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
try(mlb_people(person_ids = 502671)) try(mlb_people(person_ids = c(502671,605151)))
try(mlb_people(person_ids = 502671)) try(mlb_people(person_ids = c(502671,605151)))
Find Information About MLB Free Agents
mlb_people_free_agents(season = NULL)
mlb_people_free_agents(season = NULL)
season |
Season preceding free agency |
Returns a tibble with the following columns:
col_name | types |
date_declared | character |
notes | character |
date_signed | character |
sort_order | integer |
player_id | integer |
player_full_name | character |
player_link | character |
original_team_id | integer |
original_team_name | character |
original_team_link | character |
position_code | character |
position_name | character |
position_type | character |
position_abbreviation | character |
new_team_id | integer |
new_team_name | character |
new_team_link | character |
try(mlb_people_free_agents(season = 2018))
try(mlb_people_free_agents(season = 2018))
MLB Pitch Codes
mlb_pitch_codes()
mlb_pitch_codes()
Returns a tibble with the following columns
col_name | types |
pitch_code | character |
pitch_description | character |
try(mlb_pitch_codes())
try(mlb_pitch_codes())
MLB Pitch Types
mlb_pitch_types()
mlb_pitch_types()
Returns a tibble with the following columns
col_name | types |
pitch_type_code | character |
pitch_type_description | character |
try(mlb_pitch_types())
try(mlb_pitch_types())
Find MLB Player Game Stats
mlb_player_game_stats(person_id = NULL, game_pk = NULL)
mlb_player_game_stats(person_id = NULL, game_pk = NULL)
person_id |
MLBAMIDs for player of interest. |
game_pk |
The game_pk to return game_log statistics for a specific player in a specific game and to complete the call. |
Returns a tibble with the following columns:
col_name | types |
type | character |
group | character |
assists | integer |
put_outs | integer |
errors | integer |
chances | integer |
fielding | character |
caught_stealing | integer |
passed_ball | integer |
stolen_bases | integer |
stolen_base_percentage | character |
pickoffs | integer |
games_played | integer |
games_started | integer |
fly_outs | integer |
ground_outs | integer |
air_outs | integer |
runs | integer |
doubles | integer |
triples | integer |
home_runs | integer |
strike_outs | integer |
base_on_balls | integer |
intentional_walks | integer |
hits | integer |
hit_by_pitch | integer |
at_bats | integer |
number_of_pitches | integer |
innings_pitched | character |
wins | integer |
losses | integer |
saves | integer |
save_opportunities | integer |
holds | integer |
blown_saves | integer |
earned_runs | integer |
batters_faced | integer |
outs | integer |
games_pitched | integer |
complete_games | integer |
shutouts | integer |
pitches_thrown | integer |
balls | integer |
strikes | integer |
strike_percentage | character |
hit_batsmen | integer |
balks | integer |
wild_pitches | integer |
rbi | integer |
games_finished | integer |
runs_scored_per9 | character |
home_runs_per9 | character |
inherited_runners | integer |
inherited_runners_scored | integer |
catchers_interference | integer |
sac_bunts | integer |
sac_flies | integer |
ground_into_double_play | integer |
ground_into_triple_play | integer |
plate_appearances | integer |
total_bases | integer |
left_on_base | integer |
at_bats_per_home_run | character |
game_type | character |
num_teams | integer |
avg | character |
obp | character |
slg | character |
ops | character |
outs_pitched | integer |
whip | character |
ground_outs_to_airouts | character |
pitches_per_inning | character |
strikeout_walk_ratio | character |
strikeouts_per9inn | character |
walks_per9inn | character |
hits_per9inn | character |
team_id | integer |
team_name | character |
team_link | character |
opponent_id | integer |
opponent_name | character |
opponent_link | character |
pitcher_id | integer |
pitcher_full_name | character |
pitcher_link | character |
pitcher_first_name | character |
pitcher_last_name | character |
batter_id | integer |
batter_full_name | character |
batter_link | character |
batter_first_name | character |
batter_last_name | character |
total_splits | integer |
type_display_name | character |
group_display_name | character |
player_id | numeric |
game_pk | numeric |
try(mlb_player_game_stats(person_id = 605151, game_pk = 531368))
try(mlb_player_game_stats(person_id = 605151, game_pk = 531368))
Find MLB Player Game Stats - Current Game
mlb_player_game_stats_current(person_id = NULL)
mlb_player_game_stats_current(person_id = NULL)
person_id |
MLBAMIDs for player of interest. |
Returns a tibble with the following columns:
col_name | types |
type | character |
group | character |
stat_assists | integer |
stat_put_outs | integer |
stat_errors | integer |
stat_chances | integer |
stat_fielding | character |
stat_caught_stealing | integer |
stat_passed_ball | integer |
stat_stolen_bases | integer |
stat_stolen_base_percentage | character |
stat_pickoffs | integer |
stat_games_played | integer |
stat_games_started | integer |
stat_fly_outs | integer |
stat_ground_outs | integer |
stat_air_outs | integer |
stat_runs | integer |
stat_doubles | integer |
stat_triples | integer |
stat_home_runs | integer |
stat_strike_outs | integer |
stat_base_on_balls | integer |
stat_intentional_walks | integer |
stat_hits | integer |
stat_hit_by_pitch | integer |
stat_at_bats | integer |
stat_number_of_pitches | integer |
stat_innings_pitched | character |
stat_wins | integer |
stat_losses | integer |
stat_saves | integer |
stat_save_opportunities | integer |
stat_holds | integer |
stat_blown_saves | integer |
stat_earned_runs | integer |
stat_batters_faced | integer |
stat_outs | integer |
stat_games_pitched | integer |
stat_complete_games | integer |
stat_shutouts | integer |
stat_pitches_thrown | integer |
stat_balls | integer |
stat_strikes | integer |
stat_strike_percentage | character |
stat_hit_batsmen | integer |
stat_balks | integer |
stat_wild_pitches | integer |
stat_rbi | integer |
stat_games_finished | integer |
stat_runs_scored_per9 | character |
stat_home_runs_per9 | character |
stat_inherited_runners | integer |
stat_inherited_runners_scored | integer |
stat_catchers_interference | integer |
stat_sac_bunts | integer |
stat_sac_flies | integer |
stat_ground_into_double_play | integer |
stat_ground_into_triple_play | integer |
stat_plate_appearances | integer |
stat_total_bases | integer |
stat_left_on_base | integer |
stat_at_bats_per_home_run | character |
game_type | character |
num_teams | integer |
stat_avg | character |
stat_obp | character |
stat_slg | character |
stat_ops | character |
stat_outs_pitched | integer |
stat_whip | character |
stat_ground_outs_to_airouts | character |
stat_pitches_per_inning | character |
stat_strikeout_walk_ratio | character |
stat_strikeouts_per9inn | character |
stat_walks_per9inn | character |
stat_hits_per9inn | character |
team_id | integer |
team_name | character |
team_link | character |
opponent_id | integer |
opponent_name | character |
opponent_link | character |
pitcher_id | integer |
pitcher_full_name | character |
pitcher_link | character |
pitcher_first_name | character |
pitcher_last_name | character |
batter_id | integer |
batter_full_name | character |
batter_link | character |
batter_first_name | character |
batter_last_name | character |
total_splits | integer |
type_display_name | character |
group_display_name | character |
player_id | numeric |
game_pk | numeric |
try(mlb_player_game_stats_current(person_id = 660271))
try(mlb_player_game_stats_current(person_id = 660271))
MLB Player Status Codes
mlb_player_status_codes()
mlb_player_status_codes()
Returns a tibble with the following columns
col_name | types |
player_status_code | character |
player_status_description | character |
try(mlb_player_status_codes())
try(mlb_player_status_codes())
MLB Positions
mlb_positions()
mlb_positions()
Returns a tibble with the following columns
col_name | types |
position_short_name | character |
position_full_name | character |
position_abbreviation | character |
position_code | character |
position_type | character |
position_formal_name | character |
game_position | logical |
pitcher | logical |
fielder | logical |
outfield | logical |
position_display_name | character |
try(mlb_positions())
try(mlb_positions())
Retrieve probable starters for a given MLB game
mlb_probables(game_pk)
mlb_probables(game_pk)
game_pk |
The unique game_pk identifier for the game |
Returns a tiible that includes probable starting pitchers and
the home plate umpire for the game_pk
requested including the following columns:
col_name | types |
game_pk | integer |
game_date | character |
fullName | character |
id | integer |
team | character |
team_id | integer |
home_plate_full_name | character |
home_plate_id | integer |
try(mlb_probables(566001))
try(mlb_probables(566001))
MLB Review Reasons
mlb_review_reasons()
mlb_review_reasons()
Returns a tibble with the following columns
col_name | types |
review_reason_code | character |
review_reason_description | character |
try(mlb_review_reasons())
try(mlb_review_reasons())
MLB Roster Types
mlb_roster_types()
mlb_roster_types()
Returns a tibble with the following columns
col_name | types |
roster_type_description | character |
roster_type_lookup_name | character |
roster_type_parameter | character |
try(mlb_roster_types())
try(mlb_roster_types())
Find MLB Rosters by Roster Type
mlb_rosters(team_id = NULL, season = NULL, date = NULL, roster_type = NULL)
mlb_rosters(team_id = NULL, season = NULL, date = NULL, roster_type = NULL)
team_id |
team_id to return team roster information for a particular club. |
season |
Year to return team roster information for a particular club in a specific season. |
date |
Date to return team roster and their coaching staff directorial information for a particular team. |
roster_type |
roster_type to return team directorial information for. See |
Returns a tibble with the following columns:
col_name | types |
jersey_number | character |
person_id | integer |
person_full_name | character |
person_link | character |
position_code | character |
position_name | character |
position_type | character |
position_abbreviation | character |
status_code | character |
status_description | character |
link | character |
team_id | integer |
roster_type | character |
season | numeric |
date | character |
try(mlb_rosters(team_id = 109, season = 2018, roster_type = 'active')) try(mlb_rosters(team_id = 109, season = 2018, roster_type = 'coach'))
try(mlb_rosters(team_id = 109, season = 2018, roster_type = 'active')) try(mlb_rosters(team_id = 109, season = 2018, roster_type = 'coach'))
MLB Runner Detail Types
mlb_runner_detail_types()
mlb_runner_detail_types()
Returns a tibble with the following columns
col_name | types |
stat_name | character |
try(mlb_runner_detail_types())
try(mlb_runner_detail_types())
Find game_pk values for professional baseball games (major and minor leagues)
mlb_schedule(season = 2019, level_ids = "1")
mlb_schedule(season = 2019, level_ids = "1")
season |
The season for which you want to find game_pk values for MLB games |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
level_ids |
A numeric vector with ids for each level where game_pks are desired. See below for a reference of level ids.
|
Returns a tibble which includes game_pk
values and additional
information for games scheduled or played with the following columns:
col_name | types |
date | character |
total_items | integer |
total_events | integer |
total_games | integer |
total_games_in_progress | integer |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
inning_break_length | integer |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_reason | character |
status_abstract_game_code | character |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_home_split_squad | logical |
teams_home_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
venue_id | integer |
venue_name | character |
venue_link | character |
content_link | character |
is_tie | logical |
description | character |
teams_away_score | integer |
teams_away_is_winner | logical |
teams_home_score | integer |
teams_home_is_winner | logical |
reschedule_date | character |
reschedule_game_date | character |
rescheduled_from | character |
rescheduled_from_date | character |
resume_date | character |
resume_game_date | character |
resumed_from | character |
resumed_from_date | character |
events | list |
The following IDs can be passed to the level_ids argument:
1 = MLB
11 = Triple-A
12 = Doubl-A
13 = Class A Advanced
14 = Class A
15 = Class A Short Season
5442 = Rookie Advanced
16 = Rookie
17 = Winter League
try(mlb_schedule(season = "2019"))
try(mlb_schedule(season = "2019"))
MLB Schedule Event Types
mlb_schedule_event_types()
mlb_schedule_event_types()
Returns a tibble with the following columns
col_name | types |
schedule_event_type_code | character |
schedule_event_type_name | character |
try(mlb_schedule_event_types())
try(mlb_schedule_event_types())
Find game_pk values for professional baseball games (major and minor leagues) that are tied
mlb_schedule_games_tied(season = 2021, game_type = "S")
mlb_schedule_games_tied(season = 2021, game_type = "S")
season |
The season for which you want to find game_pk values for MLB games |
|||||||||||||||||||||||||||
game_type |
game_type to return schedule information for all tied games in a particular game_type
|
Returns a tibble that includes game_pk values and additional information for games scheduled or played
col_name | types |
date | character |
total_items | integer |
total_events | integer |
total_games | integer |
total_games_in_progress | integer |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
inning_break_length | integer |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_reason | character |
status_abstract_game_code | character |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_home_split_squad | logical |
teams_home_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
venue_id | integer |
venue_name | character |
venue_link | character |
content_link | character |
is_tie | logical |
description | character |
teams_away_score | integer |
teams_away_is_winner | logical |
teams_home_score | integer |
teams_home_is_winner | logical |
reschedule_date | character |
reschedule_game_date | character |
rescheduled_from | character |
rescheduled_from_date | character |
resume_date | character |
resume_game_date | character |
resumed_from | character |
resumed_from_date | character |
events | list |
try(mlb_schedule_games_tied(season = 2021))
try(mlb_schedule_games_tied(season = 2021))
Find game_pk values for professional baseball postseason games (major and minor leagues)
mlb_schedule_postseason( season = 2021, game_type = NULL, series_number = NULL, sport_id = 1, team_id = NULL )
mlb_schedule_postseason( season = 2021, game_type = NULL, series_number = NULL, sport_id = 1, team_id = NULL )
season |
The season for which you want to find game_pk values for MLB games |
|||||||||||||||||||||||||||
game_type |
game_type to return schedule information for all tied games in a particular game_type |
|||||||||||||||||||||||||||
series_number |
The Series number to return schedule information for all tied games in a particular series number |
|||||||||||||||||||||||||||
sport_id |
The sport_id to return schedule information for. |
|||||||||||||||||||||||||||
team_id |
The team_id to return schedule information for.
|
Returns a tibble that includes game_pk values and additional information for games scheduled or played
col_name | types |
date | character |
total_items | integer |
total_events | integer |
total_games | integer |
total_games_in_progress | integer |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
is_tie | logical |
is_featured_game | logical |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
description | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_abstract_game_code | character |
teams_away_score | integer |
teams_away_is_winner | logical |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_home_score | integer |
teams_home_is_winner | logical |
teams_home_split_squad | logical |
teams_home_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
venue_id | integer |
venue_name | character |
venue_link | character |
content_link | character |
inning_break_length | integer |
reschedule_date | character |
reschedule_game_date | character |
status_reason | character |
rescheduled_from | character |
rescheduled_from_date | character |
is_default_game | logical |
events | list |
try(mlb_schedule_postseason(season = 2021))
try(mlb_schedule_postseason(season = 2021))
Find game_pk values for professional baseball postseason series games (major and minor leagues)
mlb_schedule_postseason_series( season = 2021, game_type = NULL, series_number = NULL, sport_id = 1, team_id = NULL )
mlb_schedule_postseason_series( season = 2021, game_type = NULL, series_number = NULL, sport_id = 1, team_id = NULL )
season |
The season for which you want to find game_pk values for MLB games |
|||||||||||||||||||||||||||
game_type |
game_type to return schedule information for all tied games in a particular game_type |
|||||||||||||||||||||||||||
series_number |
The Series number to return schedule information for all tied games in a particular series number |
|||||||||||||||||||||||||||
sport_id |
The sport_id to return schedule information for. |
|||||||||||||||||||||||||||
team_id |
The team_id to return schedule information for.
|
Returns a tibble that includes game_pk values and additional information for games scheduled or played
col_name | types |
total_items | integer |
total_games | integer |
total_games_in_progress | integer |
game_pk | integer |
link | character |
game_type | character |
season | character |
game_date | character |
official_date | character |
is_tie | logical |
is_featured_game | logical |
game_number | integer |
public_facing | logical |
double_header | character |
gameday_type | character |
tiebreaker | character |
calendar_event_id | character |
season_display | character |
day_night | character |
description | character |
scheduled_innings | integer |
reverse_home_away_status | logical |
inning_break_length | integer |
games_in_series | integer |
series_game_number | integer |
series_description | character |
record_source | character |
if_necessary | character |
if_necessary_description | character |
is_default_game | logical |
status_abstract_game_state | character |
status_coded_game_state | character |
status_detailed_state | character |
status_status_code | character |
status_start_time_tbd | logical |
status_abstract_game_code | character |
teams_away_score | integer |
teams_away_is_winner | logical |
teams_away_split_squad | logical |
teams_away_series_number | integer |
teams_away_league_record_wins | integer |
teams_away_league_record_losses | integer |
teams_away_league_record_pct | character |
teams_away_team_id | integer |
teams_away_team_name | character |
teams_away_team_link | character |
teams_home_score | integer |
teams_home_is_winner | logical |
teams_home_split_squad | logical |
teams_home_series_number | integer |
teams_home_league_record_wins | integer |
teams_home_league_record_losses | integer |
teams_home_league_record_pct | character |
teams_home_team_id | integer |
teams_home_team_name | character |
teams_home_team_link | character |
venue_id | integer |
venue_name | character |
venue_link | character |
content_link | character |
reschedule_date | character |
reschedule_game_date | character |
rescheduled_from | character |
rescheduled_from_date | character |
status_reason | character |
sort_order | integer |
series_id | character |
series_sort_number | integer |
series_is_default | logical |
series_game_type | character |
try(mlb_schedule_postseason_series(season = 2021, sport_id = 1))
try(mlb_schedule_postseason_series(season = 2021, sport_id = 1))
Find MLB Seasons
mlb_seasons(sport_id = 1, with_game_type_dates = TRUE)
mlb_seasons(sport_id = 1, with_game_type_dates = TRUE)
sport_id |
The sport_id to return season information for. |
with_game_type_dates |
with_game_type_dates to return season information |
Returns a tibble with the following columns:
col_name | types |
season_id | character |
has_wildcard | logical |
pre_season_start_date | character |
pre_season_end_date | character |
season_start_date | character |
spring_start_date | character |
spring_end_date | character |
regular_season_start_date | character |
last_date1st_half | character |
all_star_date | character |
first_date2nd_half | character |
regular_season_end_date | character |
post_season_start_date | character |
post_season_end_date | character |
season_end_date | character |
offseason_start_date | character |
off_season_end_date | character |
season_level_gameday_type | character |
game_level_gameday_type | character |
qualifier_plate_appearances | numeric |
qualifier_outs_pitched | integer |
try(mlb_seasons(sport_id = 1))
try(mlb_seasons(sport_id = 1))
Find MLB Seasons all
mlb_seasons_all( sport_id = 1, division_id = NULL, league_id = NULL, with_game_type_dates = TRUE )
mlb_seasons_all( sport_id = 1, division_id = NULL, league_id = NULL, with_game_type_dates = TRUE )
sport_id |
The sport_id to return season information for. |
division_id |
The division_id to return season information for. |
league_id |
The league_id to return season information for. |
with_game_type_dates |
with_game_type_dates to return season information for. |
Returns a tibble with the following columns:
col_name | types |
season_id | character |
has_wildcard | logical |
pre_season_start_date | character |
season_start_date | character |
regular_season_start_date | character |
regular_season_end_date | character |
season_end_date | character |
offseason_start_date | character |
off_season_end_date | character |
season_level_gameday_type | character |
game_level_gameday_type | character |
qualifier_plate_appearances | numeric |
qualifier_outs_pitched | integer |
post_season_start_date | character |
post_season_end_date | character |
last_date1st_half | character |
all_star_date | character |
first_date2nd_half | character |
pre_season_end_date | character |
spring_start_date | character |
spring_end_date | character |
try(mlb_seasons_all(sport_id = 1))
try(mlb_seasons_all(sport_id = 1))
MLB Situation Codes
mlb_situation_codes()
mlb_situation_codes()
Returns a tibble with the following columns
col_name | types |
situation_code | character |
sort_order | integer |
navigation_menu | character |
situation_code_description | character |
team | logical |
batting | logical |
fielding | logical |
pitching | logical |
try(mlb_situation_codes())
try(mlb_situation_codes())
MLB Sky (Weather) Codes
mlb_sky()
mlb_sky()
Returns a tibble with the following columns
col_name | types |
sky_code | character |
sky_description | character |
try(mlb_sky())
try(mlb_sky())
MLB Sport IDs
mlb_sports(sport_id = NULL)
mlb_sports(sport_id = NULL)
sport_id |
The sport_id to return information for. |
Returns a tibble with the following columns
col_name | types |
sport_id | integer |
sport_code | character |
sport_link | character |
sport_name | character |
sport_abbreviation | character |
sort_order | integer |
active_status | logical |
and the following values:
sport_id | sport_code | sport_link | sport_name | sport_abbreviation | sort_order | active_status |
1 | mlb | /api/v1/sports/1 | Major League Baseball | MLB | 11 | TRUE |
11 | aaa | /api/v1/sports/11 | Triple-A | AAA | 101 | TRUE |
12 | aax | /api/v1/sports/12 | Double-A | AA | 201 | TRUE |
13 | afa | /api/v1/sports/13 | High-A | A+ | 301 | TRUE |
14 | afx | /api/v1/sports/14 | Low-A | A | 401 | TRUE |
16 | rok | /api/v1/sports/16 | Rookie | ROK | 701 | TRUE |
17 | win | /api/v1/sports/17 | Winter Leagues | WIN | 1301 | TRUE |
8 | bbl | /api/v1/sports/8 | Organized Baseball | Pros | 1401 | TRUE |
21 | min | /api/v1/sports/21 | Minor League Baseball | Minors | 1402 | TRUE |
23 | ind | /api/v1/sports/23 | Independent Leagues | IND | 2101 | TRUE |
51 | int | /api/v1/sports/51 | International Baseball | INT | 3501 | TRUE |
508 | nat | /api/v1/sports/508 | International Baseball (Collegiate) | INTC | 3502 | TRUE |
509 | nae | /api/v1/sports/509 | International Baseball (18 and under) | 18U | 3503 | TRUE |
510 | nas | /api/v1/sports/510 | International Baseball (16 and under) | 16U | 3505 | TRUE |
22 | bbc | /api/v1/sports/22 | College Baseball | College | 5101 | TRUE |
586 | hsb | /api/v1/sports/586 | High School Baseball | H.S. | 6201 | TRUE |
try(mlb_sports())
try(mlb_sports())
MLB Sport IDs Information
mlb_sports_info(sport_id = 1)
mlb_sports_info(sport_id = 1)
sport_id |
The sport_id to return information for. |
Returns a tibble with the following columns
col_name | types |
sport_id | integer |
sport_code | character |
sport_link | character |
sport_name | character |
sport_abbreviation | character |
sort_order | integer |
active_status | logical |
try(mlb_sports_info(sport_id = 1))
try(mlb_sports_info(sport_id = 1))
MLB Sport Players
mlb_sports_players(sport_id = 1, season = 2021)
mlb_sports_players(sport_id = 1, season = 2021)
sport_id |
The sport_id to return information for. |
season |
The season to return information for. |
Returns a tibble with the following columns:
col_name | types |
player_id | integer |
full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
is_player | logical |
is_verified | logical |
pronunciation | character |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
birth_state_province | character |
draft_year | integer |
name_matrilineal | character |
name_title | character |
last_played_date | character |
current_team_id | integer |
current_team_name | character |
current_team_link | character |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
try(mlb_sports_players(sport_id = 1, season = 2021))
try(mlb_sports_players(sport_id = 1, season = 2021))
MLB Standings
mlb_standings( season = NULL, date = NULL, standings_type = NULL, league_id = NULL )
mlb_standings( season = NULL, date = NULL, standings_type = NULL, league_id = NULL )
season |
Year(s) to return to return standings information for. |
date |
Date to return to return standings information for. |
standings_type |
The standings_type(s) to return standings information for. Description of all standings_types
|
league_id |
The league_id(s) to return standings information for. |
Returns a tibble with the following columns
col_name | types |
standings_type | character |
last_updated | character |
team_records_season | character |
team_records_clinch_indicator | character |
team_records_division_rank | character |
team_records_league_rank | character |
team_records_sport_rank | character |
team_records_games_played | integer |
team_records_games_back | character |
team_records_wild_card_games_back | character |
team_records_league_games_back | character |
team_records_spring_league_games_back | character |
team_records_sport_games_back | character |
team_records_division_games_back | character |
team_records_conference_games_back | character |
team_records_last_updated | character |
team_records_runs_allowed | integer |
team_records_runs_scored | integer |
team_records_division_champ | logical |
team_records_division_leader | logical |
team_records_has_wildcard | logical |
team_records_clinched | logical |
team_records_elimination_number | character |
team_records_wild_card_elimination_number | character |
team_records_magic_number | character |
team_records_wins | integer |
team_records_losses | integer |
team_records_run_differential | integer |
team_records_winning_percentage | character |
team_records_wild_card_rank | character |
team_records_wild_card_leader | logical |
team_records_team_id | integer |
team_records_team_name | character |
team_records_team_link | character |
team_records_streak_streak_type | character |
team_records_streak_streak_number | integer |
team_records_streak_streak_code | character |
team_records_league_record_wins | integer |
team_records_league_record_losses | integer |
team_records_league_record_ties | integer |
team_records_league_record_pct | character |
team_records_records_split_records | list |
team_records_records_division_records | list |
team_records_records_overall_records | list |
team_records_records_league_records | list |
team_records_records_expected_records | list |
league_id | integer |
league_link | character |
division_id | integer |
division_link | character |
sport_id | integer |
sport_link | character |
try(mlb_standings(season = 2021, league_id = 103))
try(mlb_standings(season = 2021, league_id = 103))
MLB Standings Types
mlb_standings_types()
mlb_standings_types()
Returns a tibble with the following columns
col_name | types |
standings_type_name | character |
standings_type_description | character |
try(mlb_standings_types())
try(mlb_standings_types())
MLB Stat Groups
mlb_stat_groups()
mlb_stat_groups()
Returns a tibble with the following columns
col_name | types |
stat_group_name | character |
try(mlb_stat_groups())
try(mlb_stat_groups())
MLB Stat Types
mlb_stat_types()
mlb_stat_types()
Returns a tibble with the following columns
col_name | types |
stat_type_name | character |
try(mlb_stat_types())
try(mlb_stat_types())
MLB Stats
mlb_stats( stat_type = NULL, player_pool = NULL, game_type = NULL, team_id = NULL, position = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_ids = NULL, sort_stat = NULL, order = NULL, limit = 1000, offset = NULL )
mlb_stats( stat_type = NULL, player_pool = NULL, game_type = NULL, team_id = NULL, position = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_ids = NULL, sort_stat = NULL, order = NULL, limit = 1000, offset = NULL )
stat_type |
Stat type to return statistics for. |
player_pool |
There are 4 different types of player pools to return statistics for a particular player pool across a sport. Acceptable values include: All, Qualified, Rookies, or Qualified_rookies |
game_type |
Game type to return information for a particular statistic in a particular game type. |
team_id |
Team ID to return information and ranking for a particular statistic for a particular team. |
position |
Position to return statistics for a given position. Default to "Qualified" player pool Acceptable values include:
|
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
league_id |
League ID to return statistics for a given league. Default to "Qualified" player pool. |
sport_ids |
The sport_id(s) to return information and ranking information for. |
sort_stat |
Sort return based on stat. |
order |
Order return based on either desc or asc. |
limit |
A limit to limit return to a particular number of records. |
offset |
An offset to returns i+1 as the first record in the set of players. |
Returns a tibble with the following columns
col_name | types |
total_splits | integer |
season | character |
num_teams | integer |
rank | integer |
games_played | integer |
ground_outs | integer |
air_outs | integer |
runs | integer |
doubles | integer |
triples | integer |
home_runs | integer |
strike_outs | integer |
base_on_balls | integer |
intentional_walks | integer |
hits | integer |
hit_by_pitch | integer |
avg | character |
at_bats | integer |
obp | character |
slg | character |
ops | character |
caught_stealing | integer |
stolen_bases | integer |
stolen_base_percentage | character |
ground_into_double_play | integer |
number_of_pitches | integer |
plate_appearances | integer |
total_bases | integer |
rbi | integer |
left_on_base | integer |
sac_bunts | integer |
sac_flies | integer |
babip | character |
ground_outs_to_airouts | character |
catchers_interference | integer |
at_bats_per_home_run | character |
team_id | integer |
team_name | character |
team_link | character |
player_id | integer |
player_full_name | character |
player_link | character |
player_first_name | character |
player_last_name | character |
league_id | integer |
league_name | character |
league_link | character |
sport_id | integer |
sport_link | character |
sport_abbreviation | character |
position_code | character |
position_name | character |
position_type | character |
position_abbreviation | character |
splits_tied_with_offset | list |
splits_tied_with_limit | list |
player_pool | character |
type_display_name | character |
group_display_name | character |
try(mlb_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
try(mlb_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Stats Leaders
mlb_stats_leaders( leader_categories = NULL, player_pool = NULL, leader_game_types = NULL, sit_codes = NULL, position = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_id = NULL, start_date = NULL, end_date = NULL, stat_type = NULL, limit = 1000 )
mlb_stats_leaders( leader_categories = NULL, player_pool = NULL, leader_game_types = NULL, sit_codes = NULL, position = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_id = NULL, start_date = NULL, end_date = NULL, stat_type = NULL, limit = 1000 )
leader_categories |
League leader category to return information and ranking for a particular statistic. |
player_pool |
There are 4 different types of player pools to return statistics for a particular player pool across a sport. Acceptable values include: All, Qualified, Rookies, or Qualified_rookies |
leader_game_types |
Game type to return information and ranking for a particular statistic in a particular game type. |
sit_codes |
Situation code to return information and ranking for a particular statistic in a particular game type. |
position |
Position to return statistics for a given position. Default to "Qualified" player pool Acceptable values include:
|
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
league_id |
League ID to return statistics for a given league. Default to "Qualified" player pool. |
sport_id |
The sport_id to return information and ranking information for. |
start_date |
Start date to return information and ranking for a particular statistic for a particular date range. Format: MM/DD/YYYY start_date must be coupled with end_date and byDateRange stat_type |
end_date |
End date to return information and ranking for a particular statistic for a particular date range. Format: MM/DD/YYYY end_date must be coupled with start_date and byDateRange stat_type |
stat_type |
The stat_type to return information and ranking for a particular statistic for a particular stat type. |
limit |
A limit to limit return to a particular number of records. |
Returns a tibble with the following columns
col_name | types |
leader_category | character |
rank | integer |
value | character |
season | character |
num_teams | integer |
team_id | integer |
team_name | character |
team_link | character |
league_id | integer |
league_name | character |
league_link | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
sport_id | integer |
sport_link | character |
sport_abbreviation | character |
stat_group | character |
total_splits | integer |
game_type_id | character |
game_type_description | character |
try(mlb_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
try(mlb_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
MLB Team Affiliates
mlb_team_affiliates(team_ids = NULL, sport_ids = NULL, season = NULL)
mlb_team_affiliates(team_ids = NULL, sport_ids = NULL, season = NULL)
team_ids |
The team_id(s) to return affiliates data for. |
sport_ids |
The sport_id to return team affiliates information for. |
season |
The season to return team affiliates data for the particular season. |
Returns a tibble with the following columns
col_name | types |
all_star_status | character |
team_id | integer |
team_full_name | character |
link | character |
season | integer |
team_code | character |
file_code | character |
team_abbreviation | character |
team_name | character |
location_name | character |
first_year_of_play | character |
short_name | character |
franchise_name | character |
club_name | character |
active | logical |
parent_org_name | character |
parent_org_id | integer |
spring_league_id | integer |
spring_league_name | character |
spring_league_link | character |
spring_league_abbreviation | character |
venue_id | integer |
venue_name | character |
venue_link | character |
spring_venue_id | integer |
spring_venue_link | character |
league_id | integer |
league_name | character |
league_link | character |
division_id | integer |
division_name | character |
division_link | character |
sport_id | integer |
sport_link | character |
sport_name | character |
try(mlb_team_affiliates(team_ids = 147))
try(mlb_team_affiliates(team_ids = 147))
MLB Team Alumni
mlb_team_alumni(team_id = NULL, stat_group = NULL, season = NULL)
mlb_team_alumni(team_id = NULL, stat_group = NULL, season = NULL)
team_id |
Team ID to return information and ranking for a particular statistic for a particular team. |
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
Returns a tibble with the following columns
col_name | types |
player_id | integer |
player_full_name | character |
link | character |
first_name | character |
last_name | character |
primary_number | character |
birth_date | character |
current_age | integer |
birth_city | character |
birth_country | character |
height | character |
weight | integer |
active | logical |
use_name | character |
middle_name | character |
boxscore_name | character |
nick_name | character |
gender | character |
name_matrilineal | character |
is_player | logical |
is_verified | logical |
pronunciation | character |
mlb_debut_date | character |
name_first_last | character |
name_slug | character |
first_last_name | character |
last_first_name | character |
last_init_name | character |
init_last_name | character |
full_fml_name | character |
full_lfm_name | character |
strike_zone_top | numeric |
strike_zone_bottom | numeric |
alumni_last_season | character |
birth_state_province | character |
draft_year | integer |
primary_position_code | character |
primary_position_name | character |
primary_position_type | character |
primary_position_abbreviation | character |
bat_side_code | character |
bat_side_description | character |
pitch_hand_code | character |
pitch_hand_description | character |
try(mlb_team_alumni(team_id = 137, stat_group = 'hitting', season = 2021))
try(mlb_team_alumni(team_id = 137, stat_group = 'hitting', season = 2021))
MLB Team Coaches
mlb_team_coaches(team_id = NULL, date = NULL, season = NULL)
mlb_team_coaches(team_id = NULL, date = NULL, season = NULL)
team_id |
Team ID to return team coach information for. |
date |
Date to return team coach information for. |
season |
Year to return team coach information for. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_id | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_team_coaches(team_id = 137, season = 2021))
try(mlb_team_coaches(team_id = 137, season = 2021))
MLB Teams History
mlb_team_history(team_ids = NULL, start_season = NULL, end_season = NULL)
mlb_team_history(team_ids = NULL, start_season = NULL, end_season = NULL)
team_ids |
The team_id(s) to return historical data for. |
start_season |
The start_season to return historical data for from the given year to present. |
end_season |
The end_season to return historical data for from the the creation to the given year. |
Returns a tibble with the following columns
col_name | types |
all_star_status | character |
team_id | integer |
team_full_name | character |
link | character |
season | integer |
team_code | character |
file_code | character |
team_abbreviation | character |
team_name | character |
location_name | character |
first_year_of_play | character |
short_name | character |
franchise_name | character |
club_name | character |
active | logical |
venue_id | integer |
venue_name | character |
venue_link | character |
spring_venue_id | integer |
spring_venue_link | character |
league_id | integer |
league_name | character |
league_link | character |
sport_id | integer |
sport_link | character |
sport_name | character |
try(mlb_team_history(team_ids = 147))
try(mlb_team_history(team_ids = 147))
MLB Team Info
mlb_team_info(team_id = NULL, season = NULL, sport_id = NULL)
mlb_team_info(team_id = NULL, season = NULL, sport_id = NULL)
team_id |
The team_id to return team data for. |
season |
The season to return team data for the given year. |
sport_id |
The sport_id to return a directory of team data for a particular club in a sport. |
Returns a tibble with the following columns
col_name | types |
all_star_status | character |
team_id | integer |
team_full_name | character |
link | character |
season | integer |
team_code | character |
file_code | character |
team_abbreviation | character |
team_name | character |
location_name | character |
first_year_of_play | character |
short_name | character |
franchise_name | character |
club_name | character |
active | logical |
venue_id | integer |
venue_name | character |
venue_link | character |
spring_venue_id | integer |
spring_venue_link | character |
league_id | integer |
league_name | character |
league_link | character |
sport_id | integer |
sport_link | character |
sport_name | character |
try(mlb_team_info(team_id = 147))
try(mlb_team_info(team_id = 147))
MLB Team Leaders
mlb_team_leaders( team_id = NULL, leader_categories = NULL, leader_game_types = NULL, season = NULL, limit = 1000 )
mlb_team_leaders( team_id = NULL, leader_categories = NULL, leader_game_types = NULL, season = NULL, limit = 1000 )
team_id |
Team ID to return team leader information for. |
leader_categories |
Team leader category to return information and ranking for a particular statistic. |
leader_game_types |
Game type to return information and ranking for a particular statistic in a particular game type. |
season |
Season to return team leader information for. |
limit |
A limit to limit return to a particular number of records. |
Returns a tibble with the following columns
col_name | types |
leader_category | character |
rank | integer |
value | character |
season | character |
team_id | integer |
team_name | character |
team_link | character |
league_id | integer |
league_name | character |
league_link | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
sport_id | integer |
sport_link | character |
sport_abbreviation | character |
stat_group | character |
total_splits | integer |
game_type_id | character |
game_type_description | character |
try(mlb_team_leaders(team_id = 137, leader_categories = "homeRuns", season = 2021))
try(mlb_team_leaders(team_id = 137, leader_categories = "homeRuns", season = 2021))
MLB Team Personnel
mlb_team_personnel(team_id = NULL, date = NULL)
mlb_team_personnel(team_id = NULL, date = NULL)
team_id |
Team ID to return team coach information for. |
date |
Date to return team coach information for. |
Returns a tibble with the following columns
col_name | types |
jersey_number | character |
job | character |
job_id | character |
title | character |
person_id | integer |
person_full_name | character |
person_link | character |
try(mlb_team_personnel(team_id = 137, date = "08/28/2016"))
try(mlb_team_personnel(team_id = 137, date = "08/28/2016"))
MLB Team Individual Stats
mlb_team_stats( team_id = NULL, stat_type = NULL, game_type = NULL, stat_group = NULL, season = NULL, sport_ids = NULL )
mlb_team_stats( team_id = NULL, stat_type = NULL, game_type = NULL, stat_group = NULL, season = NULL, sport_ids = NULL )
team_id |
Team ID to return information and ranking for a particular statistic for a particular team. |
stat_type |
Stat type to return statistics for. |
game_type |
Game type to return information for a particular statistic in a particular game type. |
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
sport_ids |
The sport_id(s) to return information and ranking information for. |
Returns a tibble with the following columns
col_name | types |
season | character |
games_played | integer |
ground_outs | integer |
air_outs | integer |
runs | integer |
doubles | integer |
triples | integer |
home_runs | integer |
strike_outs | integer |
base_on_balls | integer |
intentional_walks | integer |
hits | integer |
hit_by_pitch | integer |
avg | character |
at_bats | integer |
obp | character |
slg | character |
ops | character |
caught_stealing | integer |
stolen_bases | integer |
stolen_base_percentage | character |
ground_into_double_play | integer |
number_of_pitches | integer |
plate_appearances | integer |
total_bases | integer |
rbi | integer |
left_on_base | integer |
sac_bunts | integer |
sac_flies | integer |
babip | character |
ground_outs_to_airouts | character |
catchers_interference | integer |
at_bats_per_home_run | character |
team_id | integer |
team_name | character |
team_link | character |
type_display_name | character |
group_display_name | character |
try(mlb_team_stats(team_id = 137, stat_type = 'season', stat_group = 'hitting', season = 2021))
try(mlb_team_stats(team_id = 137, stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Teams
mlb_teams( season = NULL, active_status = NULL, all_star_statuses = NULL, league_ids = NULL, sport_ids = NULL, game_type = NULL )
mlb_teams( season = NULL, active_status = NULL, all_star_statuses = NULL, league_ids = NULL, sport_ids = NULL, game_type = NULL )
season |
Year to return to return team information for. |
active_status |
The active statuses to populate teams for a given season. |
all_star_statuses |
The all-star statuses to populate teams for a given season. |
league_ids |
The league_id(s) to return team information for. |
sport_ids |
The sport_id(s) to return team information for. |
game_type |
The game_type to return team information for. |
Returns a tibble with the following columns
col_name | types |
team_id | integer |
team_full_name | character |
link | character |
season | integer |
team_code | character |
file_code | character |
team_abbreviation | character |
team_name | character |
location_name | character |
first_year_of_play | character |
short_name | character |
franchise_name | character |
club_name | character |
all_star_status | character |
active | logical |
venue_id | integer |
venue_name | character |
venue_link | character |
spring_venue_id | integer |
spring_venue_link | character |
league_id | integer |
league_name | character |
league_link | character |
division_id | integer |
division_name | character |
division_link | character |
sport_id | integer |
sport_link | character |
sport_name | character |
spring_league_id | integer |
spring_league_name | character |
spring_league_link | character |
spring_league_abbreviation | character |
try(mlb_teams(season = 2021, sport_ids = c(1)))
try(mlb_teams(season = 2021, sport_ids = c(1)))
MLB Teams Stats
mlb_teams_stats( stat_type = NULL, game_type = NULL, stat_group = NULL, season = NULL, sport_ids = NULL, sort_stat = NULL, order = NULL )
mlb_teams_stats( stat_type = NULL, game_type = NULL, stat_group = NULL, season = NULL, sport_ids = NULL, sort_stat = NULL, order = NULL )
stat_type |
Stat type to return statistics for. |
game_type |
Game type to return information for a particular statistic in a particular game type. |
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
sport_ids |
The sport_id(s) to return information and ranking information for. |
sort_stat |
Sort return based on stat. |
order |
Order return based on either desc or asc. |
Returns a tibble with the following columns
col_name | types |
total_splits | integer |
season | character |
rank | integer |
games_played | integer |
ground_outs | integer |
air_outs | integer |
runs | integer |
doubles | integer |
triples | integer |
home_runs | integer |
strike_outs | integer |
base_on_balls | integer |
intentional_walks | integer |
hits | integer |
hit_by_pitch | integer |
avg | character |
at_bats | integer |
obp | character |
slg | character |
ops | character |
caught_stealing | integer |
stolen_bases | integer |
stolen_base_percentage | character |
ground_into_double_play | integer |
number_of_pitches | integer |
plate_appearances | integer |
total_bases | integer |
rbi | integer |
left_on_base | integer |
sac_bunts | integer |
sac_flies | integer |
babip | character |
ground_outs_to_airouts | character |
catchers_interference | integer |
at_bats_per_home_run | character |
team_id | integer |
team_name | character |
team_link | character |
splits_tied_with_offset | list |
splits_tied_with_limit | list |
type_display_name | character |
group_display_name | character |
try(mlb_teams_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
try(mlb_teams_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Teams Stats Leaders
mlb_teams_stats_leaders( leader_categories = NULL, leader_game_types = NULL, sit_codes = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_id = NULL, start_date = NULL, end_date = NULL, stat_type = NULL, limit = 1000 )
mlb_teams_stats_leaders( leader_categories = NULL, leader_game_types = NULL, sit_codes = NULL, stat_group = NULL, season = NULL, league_id = NULL, sport_id = NULL, start_date = NULL, end_date = NULL, stat_type = NULL, limit = 1000 )
leader_categories |
League leader category to return information and ranking for a particular statistic. |
leader_game_types |
Game type to return information and ranking for a particular statistic in a particular game type. |
sit_codes |
Situation code to return information and ranking for a particular statistic in a particular game type. |
stat_group |
Stat group to return information and ranking for a particular statistic in a particular group. |
season |
Year to return information and ranking for a particular statistic in a given year. |
league_id |
League ID to return statistics for a given league. Default to "Qualified" player pool. |
sport_id |
The sport_id to return information and ranking information for. |
start_date |
Start date to return information and ranking for a particular statistic for a particular date range. Format: MM/DD/YYYY start_date must be coupled with end_date and byDateRange stat_type |
end_date |
End date to return information and ranking for a particular statistic for a particular date range. Format: MM/DD/YYYY end_date must be coupled with start_date and byDateRange stat_type |
stat_type |
The stat_type to return information and ranking for a particular statistic for a particular stat type. |
limit |
A limit to limit return to a particular number of records. |
Returns a tibble with the following columns
col_name | types |
leader_category | character |
rank | integer |
value | character |
season | character |
num_teams | integer |
team_id | integer |
team_name | character |
team_link | character |
league_id | integer |
league_name | character |
league_link | character |
person_id | integer |
person_full_name | character |
person_link | character |
person_first_name | character |
person_last_name | character |
sport_id | integer |
sport_link | character |
sport_abbreviation | character |
stat_group | character |
total_splits | integer |
game_type_id | character |
game_type_description | character |
try(mlb_teams_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
try(mlb_teams_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
Find MLB Venues
mlb_venues(venue_ids = NULL, sport_ids = NULL, season = NULL)
mlb_venues(venue_ids = NULL, sport_ids = NULL, season = NULL)
venue_ids |
Venue directorial information based venue_id. |
sport_ids |
The sport_id(s) for which to return venue directorial information. |
season |
Year for which to return venue directorial information for a given season. |
Returns a tibble with the following columns:
col_name | types |
venue_id | integer |
venue_name | character |
venue_link | character |
active | logical |
season | logical |
try(mlb_venues()) try(mlb_venues(venue_ids = 4781)) try(mlb_venues(sport_ids = 1))
try(mlb_venues()) try(mlb_venues(venue_ids = 4781)) try(mlb_venues(sport_ids = 1))
MLB Wind Direction Codes
mlb_wind_direction_codes()
mlb_wind_direction_codes()
Returns a tibble with the following columns
col_name | types |
wind_direction_code | character |
wind_direction_description | character |
try(mlb_wind_direction_codes())
try(mlb_wind_direction_codes())
Most Recent MLB Season
most_recent_mlb_season()
most_recent_mlb_season()
An integer indicating the year of the most recent season of Major League Baseball
Most Recent NCAA Baseball Season
most_recent_ncaa_baseball_season()
most_recent_ncaa_baseball_season()
An integer indicating the year of the most recent season of NCAA baseball
ncaa_team_player_stats()
:This function allows the user to obtain batting or pitching statistics for any school affiliated with the NCAA at the division I, II, or III levels. The function acquires data from the NCAA's website (stats.ncaa.org) and returns a tibble.
ncaa_pbp()
:Get Play-By-Play Data for NCAA Baseball Games.
ncaa_roster()
:Get NCAA Baseball Rosters.
ncaa_game_logs()
:Get NCAA Baseball Game Logs.
ncaa_lineups()
:Get NCAA Baseball Game Lineups.
ncaa_park_factor()
:Get Park Effects for NCAA Baseball Teams.
ncaa_schedule_info()
:Get Schedule and Results for NCAA Baseball Teams.
ncaa_school_id_lu()
:Lookup NCAA School IDs (Division I, II, and III)
ncaa_teams()
:Lookup NCAA Teams by Division (I, II, and III) and Season
ncaa_team_player_stats(team_id = 255, year = 2013, type = "batting")
x <- ncaa_schedule_info(736, 2021)$game_info_url[2] ncaa_pbp(game_info_url = x)
ncaa_roster(team_id = 104, year = 2021)
ncaa_game_logs(player_id = 2113782, year = 2021, type = "pitching", span = "game")
ncaa_lineups(game_info_url="https://stats.ncaa.org/game/index/4587474?org_id=528",year=2018)
ncaa_park_factor(team_id = 736, years = c(2017:2019), type = "conference")
ncaa_schedule_info(team_id = 736, year = 2021)
ncaa_school_id_lu("VAN")
ncaa_teams(year = 2023, division = 1)
(legacy) Get NCAA Baseball Rosters
(legacy) Get NCAA Baseball Rosters
ncaa_baseball_roster(team_id = NULL, year, ...) get_ncaa_baseball_roster(team_id = NULL, year, ...)
ncaa_baseball_roster(team_id = NULL, year, ...) get_ncaa_baseball_roster(team_id = NULL, year, ...)
team_id |
NCAA id for a school |
year |
The year of interest |
... |
Additional arguments passed to an underlying function like httr. |
A data frame containing roster information, including IDs and urls for each player (if available)
A data frame containing roster information, including IDs and urls for each player (if available)
Get NCAA Baseball Game Logs
ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
player_id |
A player's unique id. Can be found using the get_ncaa_baseball_roster function. |
year |
The year of interest. |
type |
The kind of statistics you want to return. Current options are 'batting' or 'pitching'. |
span |
The span of time; can either be 'game' for game logs in a season, or 'career' which returns seasonal stats for a player's career. |
... |
Additional arguments passed to an underlying function like httr. |
A data frame containing player and school information as well as game by game statistics
col_name | types |
player_id | numeric |
player_name | character |
Date | character |
Opponent | character |
Result | character |
App | numeric |
G | numeric |
GS | numeric |
IP | numeric |
CG | numeric |
H | numeric |
R | numeric |
ER | numeric |
BB | numeric |
SO | numeric |
SHO | numeric |
BF | numeric |
P-OAB | numeric |
2B-A | numeric |
3B-A | numeric |
Bk | numeric |
HR-A | numeric |
WP | numeric |
HB | numeric |
IBB | numeric |
Inh Run | numeric |
Inh Run Score | numeric |
SHA | numeric |
SFA | numeric |
Pitches | numeric |
GO | numeric |
FO | numeric |
W | numeric |
L | numeric |
SV | numeric |
OrdAppeared | numeric |
KL | numeric |
pickoffs | character |
try(ncaa_game_logs(player_id = 2649785, year = 2023, type = "pitching", span = "game")) try(ncaa_game_logs(player_id = 2477974, year = 2023, type = "pitching", span = "career")) try(ncaa_game_logs(player_id = 2680961, year = 2023, type = "batting", span = "game")) try(ncaa_game_logs(player_id = 2486588, year = 2023, type = "batting", span = "career"))
try(ncaa_game_logs(player_id = 2649785, year = 2023, type = "pitching", span = "game")) try(ncaa_game_logs(player_id = 2477974, year = 2023, type = "pitching", span = "career")) try(ncaa_game_logs(player_id = 2680961, year = 2023, type = "batting", span = "game")) try(ncaa_game_logs(player_id = 2486588, year = 2023, type = "batting", span = "career"))
game_info_url
Retrieve lineups for a given NCAA game via its game_info_url
ncaa_lineups(game_info_url = NULL, ...)
ncaa_lineups(game_info_url = NULL, ...)
game_info_url |
The unique game info url |
... |
Additional arguments passed to an underlying function like httr. |
Returns a tibble of each school's starting lineup and starting pitcher
col_name | types |
year | numeric |
player_name | character |
position | character |
slug | character |
batting_order | character |
team_name | character |
sub | numeric |
attendance | character |
game_date | character |
location | character |
player_id | integer |
team_id | numeric |
team_url | character |
conference_id | numeric |
conference | character |
division | numeric |
season_id | numeric |
try(ncaa_lineups(game_info_url="https://stats.ncaa.org/contests/2167178/box_score")) try(ncaa_lineups(game_info_url="https://stats.ncaa.org/game/index/4587474?org_id=528"))
try(ncaa_lineups(game_info_url="https://stats.ncaa.org/contests/2167178/box_score")) try(ncaa_lineups(game_info_url="https://stats.ncaa.org/game/index/4587474?org_id=528"))
Get Park Effects for NCAA Baseball Teams
ncaa_park_factor(team_id, years, type = "conference", ...)
ncaa_park_factor(team_id, years, type = "conference", ...)
team_id |
The team's unique NCAA id. |
years |
The season or seasons (i.e. use 2016 for the 2015-2016 season, etc., limited to just 2013-2023 seasons). |
type |
default is conference. the conference parameter adjusts for the conference the school plays in, the division parameter calculates based on the division the school plays in 1,2,or 3. Defaults to 'conference'. |
... |
Additional arguments passed to an underlying function like httr. |
try(ncaa_park_factor(team_id = 736, years = c(2018:2019), type = "conference"))
A data frame with the following fields: school, home_game, away_game, runs_scored_home, runs_allowed_home, run_scored_away, runs_allowed_away, base_pf (base park factor), home_game_adj (an adjustment for the percentage of home games played) final_pf (park factor after adjustments)
col_name | types |
school | character |
home_game | numeric |
away_game | numeric |
runs_scored_home | numeric |
runs_allowed_home | numeric |
runs_scored_away | numeric |
runs_allowed_away | numeric |
base_pf | numeric |
home_game_adj | numeric |
final_pf | numeric |
Get Play-By-Play Data for NCAA Baseball Games
ncaa_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... )
ncaa_pbp( game_info_url = NA_character_, game_pbp_url = NA_character_, raw_html_to_disk = FALSE, raw_html_path = "/", read_from_file = FALSE, file = NA_character_, ... )
game_info_url |
The url for the game's boxscore data. This can be found using the ncaa_schedule_info function. |
game_pbp_url |
The url for the game's play-by-play data. This can be found using the ncaa_schedule_info function. |
raw_html_to_disk |
Write raw html to disk (saves as |
raw_html_path |
Directory path to write raw html |
read_from_file |
Read from raw html on disk |
file |
File with full path to read raw html |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with play-by-play data for an individual game.
col_name | types |
game_date | character |
location | character |
attendance | logical |
inning | character |
inning_top_bot | character |
score | character |
batting | character |
fielding | character |
description | character |
game_pbp_url | character |
game_pbp_id | integer |
try(ncaa_pbp(game_info_url = "https://stats.ncaa.org/contests/2167178/box_score"))
try(ncaa_pbp(game_info_url = "https://stats.ncaa.org/contests/2167178/box_score"))
Get NCAA Baseball Rosters
ncaa_roster(team_id = NULL, year, ...)
ncaa_roster(team_id = NULL, year, ...)
team_id |
NCAA id for a school |
year |
The year of interest |
... |
Additional arguments passed to an underlying function like httr. |
A data frame containing roster information, including IDs and urls for each player (if available)
col_name | types |
player_name | character |
class | character |
player_id | character |
season | numeric |
number | character |
position | character |
player_url | character |
team_name | character |
conference | character |
team_id | numeric |
division | numeric |
conference_id | numeric |
try(ncaa_roster(team_id = 104, year = 2023))
try(ncaa_roster(team_id = 104, year = 2023))
Get Schedule and Results for NCAA Baseball Teams
ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
team_id |
The team's unique NCAA id. |
year |
The season (i.e. use 2016 for the 2015-2016 season, etc.) |
pbp_links |
Logical parameter to run process for scraping play_by_play urls for each game |
... |
Additional arguments passed to an underlying function like httr. |
try(ncaa_schedule_info(team_id = 736, year = 2019))
A data frame with the following fields: date, opponent, result, score, innings (if more than regulation), and the url for the game itself.
col_name | types |
year | integer |
season_id | integer |
date | character |
home_team | character |
home_team_id | integer |
home_team_conference | character |
home_team_conference_id | integer |
home_team_slug | character |
home_team_division | integer |
away_team | character |
away_team_id | integer |
away_team_conference | character |
away_team_conference_id | integer |
away_team_slug | character |
away_team_division | integer |
neutral_site | character |
result | character |
score | character |
innings | character |
slug | character |
game_info_url | character |
contest_id | integer |
This function allows the user to look up the team_id
needed
for the ncaa_team_player_stats()
function.
ncaa_school_id_lu(team_name = NULL)
ncaa_school_id_lu(team_name = NULL)
team_name |
A string that will be searched for in the names of the teams. |
Returns a tibble with school identification data: team_id, team_name, team_url, conference, conference_id, division, year, and season_id
col_name | types |
team_id | numeric |
team_name | character |
team_url | character |
conference_id | numeric |
conference | character |
division | numeric |
year | numeric |
season_id | numeric |
try(ncaa_school_id_lu("Van"))
try(ncaa_school_id_lu("Van"))
(legacy) Scrape NCAA baseball Team Player Stats (Division I, II, and III)
ncaa_scrape( team_id, year = most_recent_ncaa_baseball_season(), type = "batting", ... )
ncaa_scrape( team_id, year = most_recent_ncaa_baseball_season(), type = "batting", ... )
team_id |
The numerical ID that the NCAA website uses to identify a team |
year |
The season for which data should be returned, in the form of "YYYY". Years currently available: 2013-2017. |
type |
A string indicating whether to return "batting" or "pitching" statistics |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with the following variables
col_name | types |
year | integer |
team_name | character |
team_id | numeric |
conference_id | integer |
conference | character |
division | numeric |
player_id | integer |
player_url | character |
player_name | character |
Yr | character |
Pos | character |
Jersey | character |
GP | numeric |
GS | numeric |
BA | numeric |
OBPct | numeric |
SlgPct | numeric |
R | numeric |
AB | numeric |
H | numeric |
2B | numeric |
3B | numeric |
TB | numeric |
HR | numeric |
RBI | numeric |
BB | numeric |
HBP | numeric |
SF | numeric |
SH | numeric |
K | numeric |
DP | numeric |
CS | numeric |
Picked | numeric |
SB | numeric |
RBI2out | numeric |
This function allows the user to obtain batting or pitching statistics for any school affiliated with the NCAA at the division I, II, or III levels. The function acquires data from the NCAA's website (stats.ncaa.org) and returns a tibble.
ncaa_team_player_stats( team_id, year = most_recent_ncaa_baseball_season(), type = "batting", ... )
ncaa_team_player_stats( team_id, year = most_recent_ncaa_baseball_season(), type = "batting", ... )
team_id |
The numerical ID that the NCAA website uses to identify a team |
year |
The season for which data should be returned, in the form of "YYYY". Years currently available: 2013-2017. |
type |
A string indicating whether to return "batting" or "pitching" statistics |
... |
Additional arguments passed to an underlying function like httr. |
A data frame with the following variables
col_name | types |
year | integer |
team_name | character |
team_id | numeric |
conference_id | integer |
conference | character |
division | numeric |
player_id | integer |
player_url | character |
player_name | character |
Yr | character |
Pos | character |
Jersey | character |
GP | numeric |
GS | numeric |
BA | numeric |
OBPct | numeric |
SlgPct | numeric |
R | numeric |
AB | numeric |
H | numeric |
2B | numeric |
3B | numeric |
TB | numeric |
HR | numeric |
RBI | numeric |
BB | numeric |
HBP | numeric |
SF | numeric |
SH | numeric |
K | numeric |
DP | numeric |
CS | numeric |
Picked | numeric |
SB | numeric |
RBI2out | numeric |
try(ncaa_team_player_stats(team_id = 234, year = 2023, type = "batting"))
try(ncaa_team_player_stats(team_id = 234, year = 2023, type = "batting"))
This function allows the user to obtain NCAA teams by year and division
ncaa_teams(year = most_recent_ncaa_baseball_season(), division = 1, ...)
ncaa_teams(year = most_recent_ncaa_baseball_season(), division = 1, ...)
year |
The season for which data should be returned, in the form of "YYYY". Years currently available: 2002 onward. |
division |
Division - 1, 2, 3 |
... |
Additional arguments passed to an underlying function like httr. |
ncaa_teams(2023, 1)
A data frame with the following variables
col_name | types |
team_id | character |
team_name | character |
team_url | character |
conference_id | character |
conference | character |
division | numeric |
year | numeric |
season_id | character |
(legacy) Scrape Pitcher Game Logs from FanGraphs
pitcher_game_logs_fg(playerid, year)
pitcher_game_logs_fg(playerid, year)
playerid |
This is the playerid used by FanGraphs for a given player |
year |
The season for which game logs should be returned (use the YYYY format) |
A data frame of pitcher game logs.
This function allows you to query the Chadwick Bureau's public register of baseball players and the various IDs associated with them in different systems of record.
playerid_lookup(last_name = NULL, first_name = NULL)
playerid_lookup(last_name = NULL, first_name = NULL)
last_name |
A text string used to return results for players with that string in their last name. |
first_name |
A text string used to return results for players with that string in their first name. |
A data frame of baseball players and the various IDs associated with them in different systems of record.
col_name | types |
first_name | character |
last_name | character |
given_name | character |
name_suffix | character |
nick_name | character |
birth_year | integer |
mlb_played_first | integer |
mlbam_id | integer |
retrosheet_id | character |
bbref_id | character |
fangraphs_id | integer |
try(playerid_lookup("Garcia", "Karim"))
try(playerid_lookup("Garcia", "Karim"))
This function allows you to query the Chadwick Bureau's public register of baseball players and the various IDs associated with them in different systems of record.
playername_lookup(id)
playername_lookup(id)
id |
An integer or character string representing a player ID in a baseball database, cross-referenced through the Chadwick Bureau's public register of baseball players. |
A data frame of baseball players and the various IDs associated with them in different systems of record.
col_name | types |
name_first | character |
name_last | character |
name_given | character |
name_suffix | character |
name_nick | character |
birth_year | integer |
mlb_played_first | integer |
key_mlbam | integer |
key_retro | character |
key_bbref | character |
key_fangraphs | integer |
try(playername_lookup(4885)) try(playername_lookup("kaaihki01"))
try(playername_lookup(4885)) try(playername_lookup("kaaihki01"))
This is a helper function for all statcast_search()
functions.
The function processes the initial csv payload acquired from
Baseball Savant to ensure consistency in formatting across downloads
process_statcast_payload(payload)
process_statcast_payload(payload)
payload |
payload from a Baseball Savant request |
A tibble with the processed Statcast data coerced to the correct types.
This function requires the use of the Chadwick CLI
. Follow
the directions at the repository for installation of the CLI release for your platform.
Specifically from the Chadwick CLI
tools, this function requires the cwevent
application to be available from the command line.
For unix platform users: the retrosheet_data()
function uses the system()
interface under the hood.
For Windows and other platform users: the retrosheet_data()
function interacts with the cwevent
application
using the shell()
interface under the hood.
retrosheet_data( path_to_directory = NULL, years_to_acquire = most_recent_mlb_season() - 1, sequence_years = FALSE )
retrosheet_data( path_to_directory = NULL, years_to_acquire = most_recent_mlb_season() - 1, sequence_years = FALSE )
path_to_directory |
(default: NULL) A file path that if set, either:
|
years_to_acquire |
(format: YYYY) The seasons to collect. Single, multiple, and
sequential years can be passed. If passing multiple years, enclose in a
vector (i.e. c(2017,2018)). Defaults to |
sequence_years |
(logical, default: FALSE): If the seasons passed in the years_to_acquire parameter should be sequenced so that the function returns all years including and between the vector passed, set the argument to TRUE. Defaults to FALSE. |
retrosheet_data(path_to_directory = NULL, years_to_acquire = most_recent_mlb_season()-1, sequence_years = FALSE)
If path_to_directory
is not set (default), the process will return a named list
of tibbles: 'events' and 'rosters' for each season provided to years_to_acquire
If path_to_directory
is set, will also write two csv files to the unzipped directory: 1) a combined csv
of the event data for a given year and 2) a combined csv of each team's
roster for each year provided to years_to_acquire
These functions allow a user to generate run expectancy and related measures and variables from Baseball Savant data. Measures and variables will be added to the data frame.
run_expectancy_code(df, level = "plate appearance")
run_expectancy_code(df, level = "plate appearance")
df |
A data frame generated from Baseball Savant. |
level |
Whether you want run expectancy calculated at the plate appearance or pitch level. Defaults to plate appearance. |
Returns a tibble 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 |
final_pitch_game | numeric |
final_pitch_at_bat | numeric |
runs_scored_on_pitch | numeric |
bat_score_after | numeric |
final_pitch_inning | numeric |
bat_score_start_inning | numeric |
bat_score_end_inning | numeric |
cum_runs_in_inning | numeric |
runs_to_end_inning | numeric |
count_base_out_state | character |
avg_re | numeric |
next_count_base_out_state | character |
next_avg_re | numeric |
change_re | numeric |
re24 | numeric |
try({ df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') run_expectancy_code(df, level = "plate appearances") })
try({ df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') run_expectancy_code(df, level = "plate appearances") })
(legacy) Lookup NCAA baseball school IDs (Division I, II, and III)
school_id_lu(team_name = NULL)
school_id_lu(team_name = NULL)
team_name |
A string that will be searched for in the names of the teams. |
Returns a tibble with school identification data: team_id, team_name, team_url, conference, conference_id, division, year, and season_id
(legacy) Query Baseball Savant Leaderboards
scrape_savant_leaderboards( leaderboard = "exit_velocity_barrels", year = 2020, abs = 50, min_pa = "q", min_pitches = 100, min_throws = 100, min_field = "q", min_run = 0, player_type = "batter", fielding_type = "player", oaa_position = "", oaa_roles = "", team = "", arsenal_type = "n_", run_type = "raw", min2b = 5, min3b = 0, position = "", bats = "", hand = "" )
scrape_savant_leaderboards( leaderboard = "exit_velocity_barrels", year = 2020, abs = 50, min_pa = "q", min_pitches = 100, min_throws = 100, min_field = "q", min_run = 0, player_type = "batter", fielding_type = "player", oaa_position = "", oaa_roles = "", team = "", arsenal_type = "n_", run_type = "raw", min2b = 5, min3b = 0, position = "", bats = "", hand = "" )
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, arm_strength. |
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. Can be a number or 'q' for qualified batters. |
min_pitches |
Minimum number of pitches thrown. |
min_throws |
Minimum number of throwing opportunities. |
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'. |
oaa_position |
Can be either the number position of a player or 'if' or 'of' for position categories. |
oaa_roles |
Can be either the number position of a player or 'if' or 'of' for position categories. |
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. |
Returns a tibble of Statcast leaderboard data.
(legacy) Query Statcast by Date Range and Players
scrape_statcast_savant( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant.Date( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant.default( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant_batter(start_date, end_date, batterid = NULL, ...) scrape_statcast_savant_batter_all(start_date, end_date, batterid = NULL, ...) scrape_statcast_savant_pitcher(start_date, end_date, pitcherid = NULL, ...) scrape_statcast_savant_pitcher_all(start_date, end_date, pitcherid = NULL, ...)
scrape_statcast_savant( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant.Date( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant.default( start_date = Sys.Date() - 1, end_date = Sys.Date(), playerid = NULL, player_type = "batter", ... ) scrape_statcast_savant_batter(start_date, end_date, batterid = NULL, ...) scrape_statcast_savant_batter_all(start_date, end_date, batterid = NULL, ...) scrape_statcast_savant_pitcher(start_date, end_date, pitcherid = NULL, ...) scrape_statcast_savant_pitcher_all(start_date, end_date, pitcherid = NULL, ...)
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 |
... |
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. |
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
Returns a tibble with Statcast data.
This function allows you to scrape each team's payroll from Spotrac.
sptrc_league_payrolls(year = most_recent_mlb_season())
sptrc_league_payrolls(year = most_recent_mlb_season())
year |
Year to load |
A data frame of contract data.
col_name | types |
year | character |
team | character |
team_abbr | character |
rank | numeric |
win_percent | numeric |
roster | numeric |
active_man_payroll | numeric |
injured_reserve | numeric |
retained | numeric |
buried | numeric |
suspended | numeric |
yearly_total_payroll | numeric |
try(sptrc_league_payrolls(year = most_recent_mlb_season()))
try(sptrc_league_payrolls(year = most_recent_mlb_season()))
This function allows you to scrape a team's active payroll from Spotrac.
sptrc_team_active_payroll(team_abbr, year = most_recent_mlb_season())
sptrc_team_active_payroll(team_abbr, year = most_recent_mlb_season())
team_abbr |
Team abbreviation |
year |
Year to load |
A data frame of contract data.
col_name | types |
year | numeric |
team | character |
player_name | character |
roster_status | character |
age | numeric |
pos | numeric |
status | numeric |
waiver_options | numeric |
base_salary | numeric |
signing_bonus | numeric |
payroll_salary | numeric |
adj_salary | numeric |
payroll_percent | numeric |
lux_tax_salary | numeric |
total_salary | numeric |
try(sptrc_team_active_payroll(team_abbr = "BAL", year = most_recent_mlb_season()))
try(sptrc_team_active_payroll(team_abbr = "BAL", year = most_recent_mlb_season()))
(legacy) Scrape MLB Standings on a Given Date
standings_on_date_bref(date, division, from = FALSE)
standings_on_date_bref(date, division, from = FALSE)
date |
a date object |
division |
One or more of AL East, AL Central, AL West, AL Overall, NL East, NL Central, NL West, and NL Overall |
from |
a logical indicating whether you want standings up to and including the date (FALSE, default) or rather standings for games played after the date |
Returns a tibble of MLB standings
statcast_search()
:Query Statcast by Date Range and Players.
statcast_search_batters()
:Query Statcast Batters by Date Range and Player.
statcast_search_pitchers()
:Query Statcast Pitchers by Date Range and Player.
statcast_leaderboards()
:Query Baseball Savant Leaderboards.
statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", player_type = 'batter') ## The above is equivalent to: statcast_search_batters(start_date = "2016-04-06", end_date = "2016-04-15", batterid = NULL)
statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", player_type = 'pitcher') ## The above is equivalent to: statcast_search_pitchers(start_date = "2016-04-06", end_date = "2016-04-15", pitcherid = NULL)
correa <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 621043, player_type = 'batter') ## The above is equivalent to: correa <- statcast_search_batters(start_date = "2016-04-06", end_date = "2016-04-15", batterid = 621043)
noah <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15", playerid = 592789, player_type = 'pitcher') ## The above is equivalent to: noah <- statcast_search_pitchers(start_date = "2016-04-06", end_date = "2016-04-15", pitcherid = 592789)
statcast_leaderboards(leaderboard = "exit_velocity_barrels", year = 2021)
Statcast Label Imputation
statcast_impute
statcast_impute
An object of class data.frame
with 44 rows and 4 columns.
This function allows you to read leaderboard data from BaseballSavant directly into R as data frame.
statcast_leaderboards( leaderboard = "exit_velocity_barrels", year = 2020, abs = 50, min_pa = "q", min_pitches = 100, min_throws = 100, min_field = "q", min_run = 0, player_type = "batter", fielding_type = "player", oaa_position = "", oaa_roles = "", team = "", arsenal_type = "n_", run_type = "raw", min2b = 5, min3b = 0, position = "", bats = "", hand = "" )
statcast_leaderboards( leaderboard = "exit_velocity_barrels", year = 2020, abs = 50, min_pa = "q", min_pitches = 100, min_throws = 100, min_field = "q", min_run = 0, player_type = "batter", fielding_type = "player", oaa_position = "", oaa_roles = "", team = "", arsenal_type = "n_", run_type = "raw", min2b = 5, min3b = 0, position = "", bats = "", hand = "" )
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, arm_strength. |
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. Can be a number or 'q' for qualified batters. |
min_pitches |
Minimum number of pitches thrown. |
min_throws |
Minimum number of throwing opportunities. |
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'. |
oaa_position |
Can be either the number position of a player or 'if' or 'of' for position categories. |
oaa_roles |
Can be either the number position of a player or 'if' or 'of' for position categories. |
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. |
oaa_roles argument: 30 = 1B - Straight Up 31 = 1B - Towards 1B/2B Hole 32 = 1B - Close to Line 40 = 2B - Straight Up 41 = 2B - Shaded Towards 2B Bag 42 = 2B - Towards 1B/2B Hole 43 = 2B - Behind First Basemen 46 = 2B - Up the Middle 60 = SS - Straight Up 61 = SS - Towards 3B/SS Hole 62 = SS - Shaded Towards 2B Bag 64 = SS - Up the Middle 50 = 3B - Straight Up 51 = 3B - Close to Line 52 = 3B - Towards 3B/SS Hole 77 = LF - Close to Line 71 = LF - Leaning Left 70 = LF - Straight Up 72 = LF - Leaning Right 78 = LF - LF Gap 87 = CF - LF Gap 81 = CF - Leaning Left 82 = CF - Leaning Right 89 = CF - RF Gap 98 = RF - RF Gap 91 = RF - Leaning Left 90 = RF - Straight Up 92 = RF - Leaning Right 99 = RF - Close to Line
Returns a tibble of Statcast leaderboard data with the following columns (for leaderboard: 'exit_velocity_barrels'):
col_name | types |
year | numeric |
last_name | character |
first_name | character |
player_id | integer |
attempts | integer |
avg_hit_angle | numeric |
anglesweetspotpercent | numeric |
max_hit_speed | numeric |
avg_hit_speed | numeric |
fbld | numeric |
gb | numeric |
max_distance | integer |
avg_distance | integer |
avg_hr_distance | integer |
ev95plus | integer |
ev95per-swing | numeric |
ev95percent | numeric |
barrels | integer |
brl_percent | numeric |
brl_pa | numeric |
try(statcast_leaderboards(leaderboard = "expected_statistics", year = 2018)) try(statcast_leaderboards(leaderboard = "arm_strength", year = 2020))
try(statcast_leaderboards(leaderboard = "expected_statistics", year = 2018)) try(statcast_leaderboards(leaderboard = "arm_strength", year = 2020))
This function allows you to query Statcast data as provided on https://baseballsavant.mlb.com
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, ...)
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, ...)
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 |
... |
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. |
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 |
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 |
bat_speed | character |
swing_length | character |
estimated_slg_using_speedangle | numeric |
delta_pitcher_run_exp | numeric |
hyper_speed | numeric |
home_score_diff | numeric |
bat_score_diff | numeric |
home_win_exp | numeric |
bat_win_exp | numeric |
age_pit_legacy | numeric |
age_bat_legacy | numeric |
age_pit | numeric |
age_bat | numeric |
n_thruorder_pitcher | numeric |
n_priorpa_thisgame_player_at_bat | numeric |
pitcher_days_since_prev_game | numeric |
batter_days_since_prev_game | numeric |
pitcher_days_until_next_game | numeric |
batter_days_until_next_game | numeric |
api_break_z_with_gravity | numeric |
api_break_x_arm | numeric |
api_break_x_batter_in | numeric |
arm_angle | 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 |
bat_speed | numeric |
swing_length | 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 |
bat_speed | numeric |
swing_length | numeric |
### Harper try(statcast_search(start_date = "2022-10-06", end_date = "2022-10-16", playerid = 547180, player_type = 'batter')) ### Framber try(statcast_search(start_date = "2022-10-06", end_date = "2022-10-16", playerid = 664285, player_type = 'pitcher')) ### Daily try(statcast_search(start_date = "2022-11-04", end_date = "2022-11-06")) try({ 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) }) try({ 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) })
### Harper try(statcast_search(start_date = "2022-10-06", end_date = "2022-10-16", playerid = 547180, player_type = 'batter')) ### Framber try(statcast_search(start_date = "2022-10-06", end_date = "2022-10-16", playerid = 664285, player_type = 'pitcher')) ### Daily try(statcast_search(start_date = "2022-11-04", end_date = "2022-11-06")) try({ 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) }) try({ 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) })
This function allows you to create stat lines of statistics for players or groups of players from raw Statcast. When calculating wOBA, the most recent year in the data frame is used for weighting.
statline_from_statcast(df, base = "pa")
statline_from_statcast(df, base = "pa")
df |
A data frame of statistics that includes, at a minimum, the following columns: events, description, game_date, and type. |
base |
Tells the function what to use as the population of pitches to use for the stat line. Options include "swings", "contact", or "pa". Defaults to "pa". |
statline_from_statcast(df, base = "contact")
A tibble with the additional columns calculated using the Statcast data.
An empty tibble
stats_api_live_empty_df
stats_api_live_empty_df
An object of class tbl_df
(inherits from tbl
, data.frame
) with 0 rows and 131 columns.
This function allows you to calculate team-level consistency in run scoring and run prevention over the course of an entire season.
team_consistency(year)
team_consistency(year)
year |
Season consistency should be run for. |
try(team_consistency(year=2021))
Returns a tibble with the following columns
col_name | types |
Team | character |
Con_R | numeric |
Con_RA | numeric |
Con_R_Ptile | numeric |
Con_RA_Ptile | numeric |
(legacy) Scrape Team Results
team_results_bref(Tm, year)
team_results_bref(Tm, year)
Tm |
The abbreviation used by Baseball-Reference.com for the team whose results you want to scrape. |
year |
Season for which you want to scrape the park factors. |
Returns a tibble of MLB team results
A Team Lookup Table
teams_lu_table
teams_lu_table
An object of class data.frame
with 797 rows and 31 columns.
This function allows you to calculate wOBA for any given set of data, provided the right variables are in the data set. The function currently returns both wOBA per plate appearance on wOBA per instance of fair contact.
woba_plus(df)
woba_plus(df)
df |
A data frame of statistics that includes, at a minimum, the following columns: uBB (unintentional walks), HBP (Hit By Pitch), X1B (singles), X2B (doubles), X3B (triples), HR (home runs), AB (at-bats), SH (sacrifice hits), SO (strike outs), and season. |
Returns a tibble with the wOBA factors calculated and the following columns:
col_name | types |
bbref_id | character |
season | integer |
Name | character |
Age | numeric |
Level | character |
Team | character |
G | numeric |
PA | numeric |
AB | numeric |
R | numeric |
H | numeric |
X1B | numeric |
X2B | numeric |
X3B | numeric |
HR | numeric |
RBI | numeric |
BB | numeric |
IBB | numeric |
uBB | numeric |
SO | numeric |
HBP | numeric |
SH | numeric |
SF | numeric |
GDP | numeric |
SB | numeric |
CS | numeric |
BA | numeric |
OBP | numeric |
SLG | numeric |
OPS | numeric |
wOBA | numeric |
wOBA_CON | numeric |
try({ df <- bref_daily_batter("2015-08-01", "2015-10-03") woba_plus(df) })
try({ df <- bref_daily_batter("2015-08-01", "2015-10-03") woba_plus(df) })