Title: | Acquiring and Analyzing Baseball Data |
Version: | 1.6.0 |
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/. |
License: | MIT + file LICENSE |
URL: | https://billpetti.github.io/baseballr/, https://github.com/BillPetti/baseballr |
BugReports: | https://github.com/BillPetti/baseballr/issues |
Depends: | R (≥ 4.0.0) |
Imports: | cli (≥ 3.4.1), data.table (≥ 1.14.0), dplyr (≥ 1.0.10), ggplot2, glue, httr (≥ 0.5), janitor, jsonlite, lubridate, magrittr, purrr (≥ 1.0.0), Rcpp, RcppParallel, rlang (≥ 1.0.4), rvest (≥ 1.0.0), stringr (≥ 1.3.0), tibble (≥ 3.0), tidyr (≥ 1.0.0) |
Suggests: | crayon (≥ 1.3.4), curl, DBI, furrr, future, ggrepel, knitr, pacman, progressr (≥ 0.6.0), qs (≥ 0.25.1), reshape2, rmarkdown, RSQLite, scales, stringi, stats, testthat, usethis (≥ 1.6.0), xml2 (≥ 1.3), zoo |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2024-01-15 11:27:11 UTC; saiem |
Author: | Bill Petti [aut], Saiem Gilani [aut, cre], Ben Baumer [ctb], Ben Dilday [ctb], Robert Frey [ctb], Camden Kay [ctb] |
Maintainer: | Saiem Gilani <saiem.gilani@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-01-16 12:50:02 UTC |
baseballr: 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/.
Author(s)
Maintainer: Saiem Gilani saiem.gilani@gmail.com
Authors:
Bill Petti billpetti@gmail.com
Other contributors:
Ben Baumer ben.baumer@gmail.com [contributor]
Ben Dilday ben.dilday.phd@gmail.com [contributor]
Robert Frey rfrey22@gmail.com [contributor]
Camden Kay camden.kay23@gmail.com [contributor]
See Also
Useful links:
Report bugs at https://github.com/BillPetti/baseballr/issues
(legacy) Scrape Batter Game Logs from FanGraphs
Description
(legacy) Scrape Batter Game Logs from FanGraphs
Usage
batter_game_logs_fg(playerid, year)
Arguments
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) |
Value
A data frame of batter game logs.
Baseball Reference Functions Overview
Description
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
Details
Scrape Batter Performance Data Over a Custom Time Frame
bref_daily_batter("2015-05-10", "2015-06-20")
Scrape Pitcher Performance Data Over a Custom Time Frame
bref_daily_batter("2015-05-10", "2015-06-20")
Scrape MLB Standings on a Given Date
bref_standings_on_date(date = "2015-08-04", division = "AL East")
Scrape Team Results
bref_team_results("NYM", 2015) bref_team_results(Tm="TBR", year=2008)
Team Level Consistency
Uses bref_team_results()
to calculate team consistency metrics
team_consistency(year=2015)
Scrape Batter Performance Data Over a Custom Time Frame
Description
This function allows you to scrape basic batter statistics over a custom time frame. Data is sourced from Baseball-Reference.com.
Usage
bref_daily_batter(t1, t2)
Arguments
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" |
Value
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 |
Examples
try(bref_daily_batter(t1="2015-05-10", t2="2015-06-20"))
Scrape Pitcher Performance Data Over a Custom Time Frame
Description
This function allows you to scrape basic pitcher statistics over a custom time frame. Data is sourced from Baseball-Reference.com.
Usage
bref_daily_pitcher(t1, t2)
Arguments
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" |
Value
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 |
Examples
try(bref_daily_pitcher("2015-05-10", "2015-06-20"))
Scrape MLB Standings on a Given Date
Description
This function allows you to scrape the standings from MLB for any date you choose.
Usage
bref_standings_on_date(date, division, from = FALSE)
Arguments
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 |
Value
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 |
Examples
try(bref_standings_on_date(date = "2015-08-04", division = "AL East"))
Scrape Team Results
Description
This function allows you to scrape schedule and results for a major league team from Baseball-Reference.com
Usage
bref_team_results(Tm, year)
Arguments
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. |
Value
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 |
Examples
try(bref_team_results("NYM", 2015))
try(bref_team_results(Tm="TBR", year=2008))
Chadwick Bureau Register Player Lookup
Description
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.
Details
Directly download the Chadwick Bureau's public register of baseball players.
chadwick_player_lu()
Look up baseball player name by ID
playername_lookup(4885) playername_lookup("kaaihki01")
Look up baseball player IDs by player name
playerid_lookup("Garcia", "Karim")
Check Chadwick installation
Description
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.
Usage
chadwick_path()
chadwick_is_installed()
chadwick_find_lib()
chadwick_set_ld_library_path()
chadwick_ld_library_path()
Value
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.
See Also
Examples
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
Description
Download the Chadwick Bureau's public register of baseball players
Usage
chadwick_player_lu()
get_chadwick_lu()
Value
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.
Examples
try(chadwick_player_lu())
Helper for determining whether a batted ball is a "barrel"
Description
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.
Usage
code_barrel(df)
Arguments
df |
A dataframe generated by baseballsavant.mlb.com that must include the following variables: |
Value
Returns a tibble with the additional column, barrel
.
Column structure of the MLB Draft data
Description
A tibble giving column structure of MLB Draft data
Usage
column_structure_draft_mlb
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 0 rows and 72 columns.
Load .csv / .csv.gz file from a remote connection
Description
This is a thin wrapper on data.table::fread
Usage
csv_from_url(...)
Arguments
... |
passed to data.table::fread |
(legacy) Scrape Batter Performance Data Over a Custom Time Frame
Description
(legacy) Scrape Batter Performance Data Over a Custom Time Frame
Usage
daily_batter_bref(t1, t2)
Arguments
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" |
Value
Returns a tibble of batter performance
See Also
bref_daily_batter()
(legacy) Scrape Pitcher Performance Data Over a Custom Time Frame
Description
(legacy) Scrape Pitcher Performance Data Over a Custom Time Frame
Usage
daily_pitcher_bref(t1, t2)
Arguments
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" |
Value
Returns a tibble of pitcher performance
See Also
bref_daily_pitcher()
Edge Code
Description
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.
Usage
edge_code(df, height_var_name = "b_height")
Arguments
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) |
Value
Returns a tibble with the additional edge columns necessary for calculations.
Edge Percentage Frequency
Description
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.
Usage
edge_frequency(df, group = NULL)
Arguments
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. |
Value
Returns a tibble with the additional edge columns necessary for frequency calculations.
FanGraphs Functions Overview
Description
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.
Details
Scrape Pitcher Game Logs from FanGraphs
fg_pitcher_game_logs(playerid = 104, year = 2006)
Scrape Batter Game Logs from FanGraphs
fg_batter_game_logs(playerid = 6184, year = 2017)
Scrape MiLB game logs for pitchers from Fangraphs
fg_milb_pitcher_game_logs(playerid = "sa3004210", year=2017)
Scrape MiLB game logs for batters from Fangraphs
fg_milb_batter_game_logs(playerid = "sa917940", year=2018)
Scrape Batter Leaderboards from FanGraphs
fg_batter_leaders(startseason = 2015, endseason = 2015, qual = 400)
Scrape Pitcher Leaderboards from FanGraphs
fg_pitcher_leaders(startseason = 2015, endseason = 2015, qual = 150)
Scrape Fielder Leaderboards from FanGraphs
fg_fielder_leaders(startseason = 2015, endseason = 2015, qual = 150)
Scrape Team Batter Leaderboards from FanGraphs
fg_team_batter(startseason = 2015, endseason = 2015, qual = 400)
Scrape Team Pitcher Leaderboards from FanGraphs
fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150)
Scrape Team Fielder Leaderboards from FanGraphs
fg_team_fielder(startseason = 2015, endseason = 2015, qual = 150)
Scrape FanGraphs.com Guts!
fg_guts()
Scrape Park Factors from FanGraphs.com
fg_park(2013)
Scrape Park Factors by handedness from FanGraphs.com
fg_park_hand(2013)
(legacy) Scrape Batter Leaderboards from FanGraphs
Description
(legacy) Scrape Batter Leaderboards from FanGraphs
(legacy) Scrape Batter Leaderboards from FanGraphs
Usage
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"
)
Arguments
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". |
Value
A data frame of batter data.
A data frame of batter data.
Scrape Batter Game Logs from FanGraphs
Description
This function allows you to scrape game logs by year for a batter from FanGraphs.com.
Usage
fg_batter_game_logs(playerid, year)
Arguments
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) |
Value
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 |
Examples
try(fg_batter_game_logs(playerid = 19755, year = 2023))
Scrape Batter Leaderboards from FanGraphs
Description
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_batter_leaders(startseason = 2023, endseason = 2023))
Scrape Fielder Leaderboards from FanGraphs
Description
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_fielder_leaders(startseason = 2023, endseason = 2023))
Scrape FanGraphs.com Guts!
Description
Scrape historical FanGraphs Guts! table, wOBA, FIP coefficients and constants
Usage
fg_guts()
Value
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 |
Examples
try(fg_guts())
Scrape MiLB game logs for batters from FanGraphs
Description
This function allows you to scrape MiLB game logs for individual batters from FanGraphs.
Usage
fg_milb_batter_game_logs(playerid, year)
Arguments
playerid |
The batter's minor league ID from FanGraphs. |
year |
The season for which game logs should be returned. |
Value
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 |
Examples
try(fg_milb_batter_game_logs(playerid = "sa3019999", year=2023))
Scrape MiLB game logs for pitchers from FanGraphs
Description
This function allows you to scrape MiLB game logs for individual batters from FanGraphs.com.
Usage
fg_milb_pitcher_game_logs(playerid, year)
Arguments
playerid |
The pitcher's minor league ID from FanGraphs.com. |
year |
The season for which game logs should be returned. |
Value
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 |
Examples
try(fg_milb_pitcher_game_logs(playerid = "sa3020682", year=2023))
Scrape Park Factors from FanGraphs
Description
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.
Usage
fg_park(yr)
fg_park_hand(yr)
Arguments
yr |
Season for which you want to scrape the park factors. |
Value
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 |
Examples
try(fg_park(2013))
try(fg_park_hand(2013))
(legacy) Scrape Pitcher Leaderboards from FanGraphs
Description
(legacy) Scrape Pitcher Leaderboards from FanGraphs
Usage
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"
)
Arguments
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". |
Value
A data frame of pitcher data.
Scrape Pitcher Game Logs from FanGraphs
Description
This function allows you to scrape game logs by year for a pitcher from FanGraphs.com.
Usage
fg_pitcher_game_logs(playerid, year)
Arguments
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) |
Value
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 |
Examples
try(fg_pitcher_game_logs(playerid = "19755", year = 2023))
Scrape Pitcher Leaderboards from FanGraphs
Description
Scrape Pitcher Leaderboards from FanGraphs
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_pitcher_leaders(startseason = 2023, endseason = 2023))
Scrape Team Batter Leaderboards from FanGraphs
Description
This function allows you to scrape all leaderboard statistics (basic and advanced) from FanGraphs.com.
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_team_batter(startseason = 2015, endseason = 2015, qual = 200))
Scrape Team Fielder Leaderboards from FanGraphs
Description
Scrape Team Fielder Leaderboards from FanGraphs
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150))
Scrape Team Pitcher Leaderboards from FanGraphs
Description
Scrape Team Pitcher Leaderboards from FanGraphs
Usage
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"
)
Arguments
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". |
Value
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 |
Examples
try(fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150))
Calculate FIP and related metrics for any set of data
Description
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.
Usage
fip_plus(df)
Arguments
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. |
Value
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 |
Examples
try({
df <- bref_daily_pitcher("2015-04-05", "2015-04-30")
fip_plus(df)
})
(legacy) Retrieve batting orders for a given MLB game
Description
(legacy) Retrieve batting orders for a given MLB game
Usage
get_batting_orders(game_pk, type = "starting")
Arguments
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') |
Value
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
Description
(legacy) Retrieve draft pick information by year
Usage
get_draft_mlb(year)
Arguments
year |
The year for which to return data |
Value
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
Description
(legacy) Retrieve additional game information for major and minor league games
Usage
get_game_info_mlb(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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.
Description
(legacy) Download a data frame of supplemental data about MLB games since 2008.
Usage
get_game_info_sup_petti()
Value
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
Description
(legacy) Get MLB Game Info by Date and Level
Usage
get_game_pks_mlb(date, level_ids = c(1))
Arguments
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. |
Value
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
Description
(legacy) Get Play-By-Play Data for NCAA Baseball Games
(legacy) Get Play-By-Play Data for NCAA Baseball Games
Usage
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_,
...
)
Arguments
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. |
Value
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
Description
(legacy) Get NCAA Baseball Game Logs
Usage
get_ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
Arguments
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. |
Value
A data frame containing player and school information as well as game by game statistics
(legacy) Retrieve lineups for a given NCAA game via its game_info_url
Description
(legacy) Retrieve lineups for a given NCAA game via its game_info_url
Usage
get_ncaa_lineups(game_info_url = NULL, ...)
Arguments
game_info_url |
The unique game info url |
... |
Additional arguments passed to an underlying function like httr. |
Value
Returns a tibble of each school's starting lineup and starting pitcher
(legacy) Get Park Effects for NCAA Baseball Teams
Description
(legacy) Get Park Effects for NCAA Baseball Teams
Usage
get_ncaa_park_factor(team_id, years, type = "conference", ...)
Arguments
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. |
Value
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
Description
(legacy) Get Schedule and Results for NCAA Baseball Teams
Usage
get_ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
Arguments
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. |
Value
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
Description
(legacy) Acquire pitch-by-pitch data for Major and Minor League games
(legacy) Acquire pitch-by-pitch data for Major and Minor League games
Usage
get_pbp_mlb(game_pk)
get_pbp_mlb(game_pk)
Arguments
game_pk |
The date for which you want to find game_pk values for MLB games |
Value
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
Description
(legacy) Retrieve probable starters for a given MLB game
Usage
get_probables_mlb(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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
Description
(legacy) Get, Parse, and Format Retrosheet Event and Roster Files
Usage
get_retrosheet_data(
path_to_directory = NULL,
years_to_acquire = most_recent_mlb_season() - 1,
sequence_years = FALSE
)
Arguments
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. |
Value
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
Description
(legacy) Download a data frame of all umpires and their MLBAM IDs for games since 2008
Usage
get_umpire_ids_petti()
Value
Function returns a tibble with the following columns:
id
position,
name
game_pk
game_date
Generate spray charts with ggplot2
Description
This function allows you to create spray charts with ggplots given a data frame with batted ball location coordinates.
Usage
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
)
Arguments
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. |
Details
ggspraychart(df, x_value = "hc_x", y_value = "-hc_y", fill_value = "events")
Value
A plot of the spraychart for the supplied dataset
Label Statcast data as imputed
Description
Based on a series of heuristics, this function attempts to label Statcast data for which the launch angle and speed have been imputed.
Usage
label_statcast_imputed_data(
statcast_df,
impute_file = NULL,
inverse_precision = 10000
)
Arguments
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 |
Value
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 |
Examples
try({
statcast_df <- statcast_search("2017-05-01", "2017-05-02")
sc_df <- label_statcast_imputed_data(statcast_df)
mean(sc_df$imputed)
})
Generate linear weight values for events using Baseball Savant data
Description
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.
Usage
linear_weights_savant(df, level = "plate appearance")
Arguments
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'. |
Value
Returns a tibble with the following columns:
col_name | types |
events | character |
linear_weights_above_average | numeric |
linear_weights_above_outs | numeric |
Examples
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.
Description
Download a data frame of supplemental data about MLB games since 2008.
Usage
load_game_info_sup()
Value
Function returns a tibble with various columns, including:
game_pk
game_date
venue id
attendance
game temperature
wind speed
direction
start time
end time
Examples
try(load_game_info_sup())
Load cleaned NCAA baseball play-by-play data from the baseballr data repo
Description
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
Usage
load_ncaa_baseball_pbp(
seasons = most_recent_ncaa_baseball_season(),
...,
dbConnection = NULL,
tablename = NULL
)
Arguments
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 |
Value
Returns a tibble
Examples
try(load_ncaa_baseball_pbp(seasons = 2021))
Load cleaned NCAA baseball schedule from the baseballr data repo
Description
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
Usage
load_ncaa_baseball_schedule(
seasons = most_recent_ncaa_baseball_season(),
...,
dbConnection = NULL,
tablename = NULL
)
Arguments
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 |
Value
Returns a tibble
Examples
try(load_ncaa_baseball_schedule(seasons = 2022))
Load cleaned NCAA men's college baseball season IDs from the baseballr data repo
Description
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
Usage
load_ncaa_baseball_season_ids(..., dbConnection = NULL, tablename = NULL)
Arguments
... |
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 |
Value
Returns a tibble
Examples
try(load_ncaa_baseball_season_ids())
Load cleaned NCAA men's college baseball teams from the baseballr data repo
Description
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
Usage
load_ncaa_baseball_teams(..., dbConnection = NULL, tablename = NULL)
Arguments
... |
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 |
Value
Returns a tibble
Examples
try(load_ncaa_baseball_teams())
Download a data frame of all umpires and their mlbamids for games since 2008
Description
Download a data frame of all umpires and their mlbamids for games since 2008
Usage
load_umpire_ids()
Value
Function returns a tibble with the following columns:
id
position
name
game_pk
game_date
Examples
try(load_umpire_ids())
Metrics Functions Overview
Description
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.
Details
Calculate Team-level Consistency
team_consistency(year=2015)
Calculate FIP and related metrics for any set of data
fips_plus(df)
Calculate wOBA and related metrics for any set of data
woba_plus(df)
Label Statcast data as imputed
statcast_df <- scrape_statcast_savant("2017-05-01", "2017-05-02") sc_df <- label_statcast_imputed_data(statcast_df) mean(sc_df$imputed)
Generate run expectancy and related measures from Baseball Savant data
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")
Generate linear weight values for events using Baseball Savant data
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
Description
(legacy) Scrape MiLB game logs for batters from FanGraphs
Usage
milb_batter_game_logs_fg(playerid, year)
Arguments
playerid |
The batter's minor league ID from FanGraphs. |
year |
The season for which game logs should be returned. |
Value
Returns a tibble of Minor League batter game logs.
(legacy) Scrape MiLB game logs for pitchers from FanGraphs
Description
(legacy) Scrape MiLB game logs for pitchers from FanGraphs
Usage
milb_pitcher_game_logs_fg(playerid, year)
Arguments
playerid |
The pitcher's minor league ID from FanGraphs.com. |
year |
The season for which game logs should be returned. |
Value
Returns a tibble of Minor League pitcher game logs.
MLB Functions Overview
Description
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.
Details
Retrieve batting orders for a given MLB game
mlb_batting_orders(game_pk=566001)
Retrieve draft pick information by year
mlb_draft(year= 2018)
Acquire pitch-by-pitch data for Major and Minor League games
mlb_pbp(game_pk = 575156)
Retrieve additional game information for major and minor league games
mlb_game_info(game_pk = 566001)
Get MLB Game Info by Date and Level
mlb_game_pks("2019-04-29")
Find game_pk values for professional baseball games (major and minor leagues)
mlb_schedule(season = "2019")
Retrieve probable starters for a given MLB game
mlb_probables(566001)
Find MLB All-Star Ballots
Description
Find MLB All-Star Ballots
Usage
mlb_all_star_ballots(league_id = NULL, season = NULL)
Arguments
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Value
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 |
Examples
try(mlb_all_star_ballots(league_id = 103, season = 2021))
Find MLB All-Star Final Vote
Description
Find MLB All-Star Final Vote
Usage
mlb_all_star_final_vote(league_id = NULL, season = NULL)
Arguments
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Value
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 |
Examples
try(mlb_all_star_final_vote(league_id = 103, season = 2021))
Find MLB All-Star Write-ins
Description
Find MLB All-Star Write-ins
Usage
mlb_all_star_write_ins(league_id = NULL, season = NULL)
Arguments
league_id |
League ID for league all-star ballot of interest. |
season |
The season of the all-star ballot. |
Value
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 |
Examples
try(mlb_all_star_write_ins(league_id = 103, season = 2021))
MLB Attendance
Description
MLB Attendance
Usage
mlb_attendance(
team_id = NULL,
league_id = NULL,
season = NULL,
date = NULL,
league_list_id = NULL
)
Arguments
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:
|
Value
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 |
Examples
try(mlb_attendance(team_id = 109, season = 2021))
MLB All-Star, Awards, Home Run Derby Functions
Description
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.
Details
Find MLB All-Star Ballots
try(mlb_all_star_ballots(league_id = 103, season = 2021))
Find MLB All-Star Final Vote
try(mlb_all_star_final_vote(league_id = 103, season = 2021))
Find MLB All-Star Write-ins
try(mlb_all_star_write_ins(league_id = 103, season = 2021))
Find MLB Awards
try(mlb_awards())
Find MLB Award Recipients
try(mlb_awards_recipient(award_id = 'MLBHOF', season = 2020))
Retrieve MLB Home Run Derby Data
try(mlb_homerun_derby(game_pk = 511101))
Retrieve MLB Home Run Derby Bracket
try(mlb_homerun_derby_bracket(game_pk = 511101))
Retrieve MLB Home Run Derby Players
try(mlb_homerun_derby_players(game_pk = 511101))
MLB Awards
Description
MLB Awards
Usage
mlb_awards()
Value
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 |
Examples
try(mlb_awards())
MLB Award Recipients
Description
MLB Award Recipients
Usage
mlb_awards_recipient(
award_id = NULL,
sport_id = NULL,
league_id = NULL,
season = NULL
)
Arguments
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. |
Value
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 |
Examples
try(mlb_awards_recipient(award_id = 'MLBHOF', season = 2020))
MLB Baseball Stats
Description
MLB Baseball Stats
Usage
mlb_baseball_stats()
Value
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 |
Examples
try(mlb_baseball_stats())
Retrieve batting orders for a given MLB game
Description
Retrieve batting orders for a given MLB game
Usage
mlb_batting_orders(game_pk, type = "starting")
Arguments
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') |
Value
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 |
Examples
try(mlb_batting_orders(game_pk=566001))
View all PCL conferences
Description
View all PCL conferences
Usage
mlb_conferences(conference_id = NULL, season = NULL)
Arguments
conference_id |
Conference ID to return information for. |
season |
Year to return to return conference information for. |
Value
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 |
Examples
try(mlb_conferences())
try(mlb_conferences(conference_id = 301, season = 2020))
MLB Divisions
Description
MLB Divisions
Usage
mlb_divisions(division_id = NULL, league_id = NULL, sport_id = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_divisions(sport_id = 1))
Retrieve draft pick information by year
Description
Retrieve draft pick information by year
Usage
mlb_draft(year)
Arguments
year |
The year for which to return data |
Value
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 |
Examples
try(mlb_draft(year = 2020))
Retrieve latest draft information by year
Description
Retrieve latest draft information by year
Usage
mlb_draft_latest(year)
Arguments
year |
The year for which to return data |
Value
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 |
Examples
try(mlb_draft_latest(year = 2020))
Retrieve draft prospect information by year
Description
Retrieve draft prospect information by year
Usage
mlb_draft_prospects(year)
Arguments
year |
The year for which to return data |
Value
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 |
Examples
try(mlb_draft_prospects(year = 2020))
MLB Event Types
Description
MLB Event Types
Usage
mlb_event_types()
Value
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 |
Examples
try(mlb_event_types())
MLB Fielder Detail Types
Description
MLB Fielder Detail Types
Usage
mlb_fielder_detail_types()
Value
Returns a tibble with the following columns
col_name | types |
stat_name | character |
code | character |
names | character |
chance | logical |
error | logical |
Examples
try(mlb_fielder_detail_types())
Acquire time codes for Major and Minor League games
Description
Acquire time codes for Major and Minor League games
Usage
mlb_game_changes(updated_since, sport_id)
Arguments
updated_since |
Updated since date time |
sport_id |
Return division(s) for all divisions in a specific sport. |
Value
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 |
Examples
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
Description
Retrieve additional game content for major and minor league games
Usage
mlb_game_content(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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 |
Examples
try(mlb_game_content(game_pk = 566001))
Acquire game context metrics for Major and Minor League games
Description
Acquire game context metrics for Major and Minor League games
Usage
mlb_game_context_metrics(game_pk, timecode)
Arguments
game_pk |
The game_pk for the game requested |
timecode |
The time code for the MLB game (format: MMDDYYYY_HHMMSS) |
Value
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 |
Examples
try(mlb_game_context_metrics(game_pk = 531060, timecode = "20180803_182458"))
Retrieve additional game information for major and minor league games
Description
Retrieve additional game information for major and minor league games
Usage
mlb_game_info(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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 |
Examples
try(mlb_game_info(game_pk = 566001))
Retrieve game linescores for major and minor league games
Description
Retrieve game linescores for major and minor league games
Usage
mlb_game_linescore(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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 |
Examples
try(mlb_game_linescore(game_pk = 566001))
Retrieve game pace metrics for major and minor league
Description
Retrieve game pace metrics for major and minor league
Usage
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
)
Arguments
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. |
Value
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 |
Examples
try(mlb_game_pace(season = 2021, start_date = "09/14/2021", end_date = "09/16/2021"))
Get MLB Game Info by Date and Level
Description
Find game_pk values for professional baseball games (major and minor leagues) via the MLB api https://www.mlb.com/
Usage
mlb_game_pks(date, level_ids = c(1))
Arguments
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. |
Details
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
Value
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 |
Examples
try(mlb_game_pks("2019-04-29"))
MLB Game Status Codes
Description
MLB Game Status Codes
Usage
mlb_game_status_codes()
Value
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 |
Examples
try(mlb_game_status_codes())
Acquire time codes for Major and Minor League games
Description
Acquire time codes for Major and Minor League games
Usage
mlb_game_timecodes(game_pk)
Arguments
game_pk |
The game_pk for the game requested |
Value
Returns a tibble that includes time codes from the game_pk requested
col_name | types |
timecodes (MMDDYYYY_HHMMSS) | numeric |
Examples
try(mlb_game_timecodes(game_pk = 632970))
MLB Game Types
Description
MLB Game Types
Usage
mlb_game_types()
Value
Returns a tibble with the following columns
col_name | types |
game_type_id | character |
game_type_description | character |
Examples
try(mlb_game_types())
Acquire win probability for Major and Minor League games
Description
Acquire win probability for Major and Minor League games
Usage
mlb_game_wp(game_pk, timecode = NULL)
Arguments
game_pk |
The game_pk for the game requested |
timecode |
The time code for the MLB game (format: MMDDYYYY_HHMMSS) |
Value
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 |
Examples
try(mlb_game_wp(game_pk = 531060))
Acquire high/low stats for Major and Minor Leagues
Description
Acquire high/low stats for Major and Minor Leagues
Usage
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
)
Arguments
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. |
Value
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 |
Examples
try(mlb_high_low_stats(org_type = 'Team', season = 2020, sort_stat = 'atBats'))
MLB Stat High/Low Types
Description
MLB Stat High/Low Types
Usage
mlb_high_low_types()
Value
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 |
Examples
try(mlb_high_low_types())
MLB Hit Trajectories
Description
MLB Hit Trajectories
Usage
mlb_hit_trajectories()
Value
Returns a tibble with the following columns
col_name | types |
hit_trajectory_code | character |
hit_trajectory_description | character |
Examples
try(mlb_hit_trajectories())
Retrieve Homerun Derby data
Description
Retrieve Homerun Derby data
Usage
mlb_homerun_derby(game_pk)
Arguments
game_pk |
The game_pk for which you want to return data |
Value
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 |
Examples
try(mlb_homerun_derby(game_pk = 511101))
Retrieve Homerun Derby Bracket
Description
Retrieve Homerun Derby Bracket
Usage
mlb_homerun_derby_bracket(game_pk)
Arguments
game_pk |
The game_pk for which you want to return data |
Value
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 |
Examples
try(mlb_homerun_derby_bracket(game_pk = 511101))
Retrieve Homerun Derby Players
Description
Retrieve Homerun Derby Players
Usage
mlb_homerun_derby_players(game_pk)
Arguments
game_pk |
The game_pk for which you want to return data |
Value
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 |
Examples
try(mlb_homerun_derby_players(game_pk = 511101))
MLB Job Types
Description
MLB Job Types
Usage
mlb_job_types()
Value
Returns a tibble with the following columns
col_name | types |
job_code | character |
job | character |
sort_order | integer |
Examples
try(mlb_job_types())
MLB Jobs
Description
MLB Jobs
Usage
mlb_jobs(job_type = "UMPR", sport_id = NULL, date = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_jobs(job_type='UMPR'))
MLB Jobs Datacasters
Description
MLB Jobs Datacasters
Usage
mlb_jobs_datacasters(sport_id = NULL, date = NULL)
Arguments
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Value
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 |
Examples
try(mlb_jobs_datacasters(sport_id=1))
MLB Jobs Official Scorers
Description
MLB Jobs Official Scorers
Usage
mlb_jobs_official_scorers(sport_id = NULL, date = NULL)
Arguments
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Value
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 |
Examples
try(mlb_jobs_official_scorers(sport_id=1))
MLB Jobs Umpires
Description
MLB Jobs Umpires
Usage
mlb_jobs_umpires(sport_id = NULL, date = NULL)
Arguments
sport_id |
Return information for a given sport_id. |
date |
Return information for a given date. |
Value
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 |
Examples
try(mlb_jobs_umpires(sport_id=1))
MLB API Language Options
Description
MLB API Language Options
Usage
mlb_languages()
Value
Returns a tibble with the following columns
col_name | types |
language_name | character |
language_code | character |
locale | character |
Examples
try(mlb_languages())
MLB Leagues
Description
MLB Leagues
Usage
mlb_league(seasons = NULL, sport_id = NULL, league_id = NULL)
Arguments
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. |
Value
Returns a tibble with the following columns
col_name | types |
leader_type | character |
Examples
try(mlb_league(seasons = 2021, sport_id = 1))
MLB League Leader Types
Description
MLB League Leader Types
Usage
mlb_league_leader_types()
Value
Returns a tibble with the following columns
col_name | types |
leader_type | character |
Examples
try(mlb_league_leader_types())
MLB Logical Events
Description
MLB Logical Events
Usage
mlb_logical_events()
Value
Returns a tibble with the following columns
col_name | types |
event_code | character |
Examples
try(mlb_logical_events())
MLB Metrics
Description
MLB Metrics
Usage
mlb_metrics()
Value
Returns a tibble with the following columns
col_name | types |
metric_name | character |
metric_id | integer |
stat_group | character |
metric_unit | character |
Examples
try(mlb_metrics())
Acquire pitch-by-pitch data for Major and Minor League games
Description
Acquire pitch-by-pitch data for Major and Minor League games
Usage
mlb_pbp(game_pk)
Arguments
game_pk |
The date for which you want to find game_pk values for MLB games |
Value
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 |
Examples
try(mlb_pbp(game_pk = 632970))
Acquire pitch-by-pitch data between two timecodes for Major and Minor League games
Description
Acquire pitch-by-pitch data between two timecodes for Major and Minor League games
Usage
mlb_pbp_diff(game_pk, start_timecode, end_timecode)
Arguments
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) |
Value
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 |
Examples
try(mlb_pbp_diff(game_pk = 632970,
start_timecode = "20210808_231704",
end_timecode = "20210808_233711"))
Find Biographical Information for MLB Players
Description
Find Biographical Information for MLB Players
Usage
mlb_people(person_ids = NULL)
Arguments
person_ids |
MLBAMIDs for players of interest. Multiple IDs should be provided in a vector separated by a comma. |
Value
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 |
Examples
try(mlb_people(person_ids = 502671))
try(mlb_people(person_ids = c(502671,605151)))
Find Information About MLB Free Agents
Description
Find Information About MLB Free Agents
Usage
mlb_people_free_agents(season = NULL)
Arguments
season |
Season preceding free agency |
Value
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 |
Examples
try(mlb_people_free_agents(season = 2018))
MLB Pitch Codes
Description
MLB Pitch Codes
Usage
mlb_pitch_codes()
Value
Returns a tibble with the following columns
col_name | types |
pitch_code | character |
pitch_description | character |
Examples
try(mlb_pitch_codes())
MLB Pitch Types
Description
MLB Pitch Types
Usage
mlb_pitch_types()
Value
Returns a tibble with the following columns
col_name | types |
pitch_type_code | character |
pitch_type_description | character |
Examples
try(mlb_pitch_types())
Find MLB Player Game Stats
Description
Find MLB Player Game Stats
Usage
mlb_player_game_stats(person_id = NULL, game_pk = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_player_game_stats(person_id = 605151, game_pk = 531368))
Find MLB Player Game Stats - Current Game
Description
Find MLB Player Game Stats - Current Game
Usage
mlb_player_game_stats_current(person_id = NULL)
Arguments
person_id |
MLBAMIDs for player of interest. |
Value
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 |
Examples
try(mlb_player_game_stats_current(person_id = 660271))
MLB Player Status Codes
Description
MLB Player Status Codes
Usage
mlb_player_status_codes()
Value
Returns a tibble with the following columns
col_name | types |
player_status_code | character |
player_status_description | character |
Examples
try(mlb_player_status_codes())
MLB Positions
Description
MLB Positions
Usage
mlb_positions()
Value
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 |
Examples
try(mlb_positions())
Retrieve probable starters for a given MLB game
Description
Retrieve probable starters for a given MLB game
Usage
mlb_probables(game_pk)
Arguments
game_pk |
The unique game_pk identifier for the game |
Value
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 |
Examples
try(mlb_probables(566001))
MLB Review Reasons
Description
MLB Review Reasons
Usage
mlb_review_reasons()
Value
Returns a tibble with the following columns
col_name | types |
review_reason_code | character |
review_reason_description | character |
Examples
try(mlb_review_reasons())
MLB Roster Types
Description
MLB Roster Types
Usage
mlb_roster_types()
Value
Returns a tibble with the following columns
col_name | types |
roster_type_description | character |
roster_type_lookup_name | character |
roster_type_parameter | character |
Examples
try(mlb_roster_types())
Find MLB Rosters by Roster Type
Description
Find MLB Rosters by Roster Type
Usage
mlb_rosters(team_id = NULL, season = NULL, date = NULL, roster_type = NULL)
Arguments
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 |
Value
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 |
Examples
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
Description
MLB Runner Detail Types
Usage
mlb_runner_detail_types()
Value
Returns a tibble with the following columns
col_name | types |
stat_name | character |
Examples
try(mlb_runner_detail_types())
Find game_pk values for professional baseball games (major and minor leagues)
Description
Find game_pk values for professional baseball games (major and minor leagues)
Usage
mlb_schedule(season = 2019, level_ids = "1")
Arguments
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.
|
Value
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 |
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
Examples
try(mlb_schedule(season = "2019"))
MLB Schedule Event Types
Description
MLB Schedule Event Types
Usage
mlb_schedule_event_types()
Value
Returns a tibble with the following columns
col_name | types |
schedule_event_type_code | character |
schedule_event_type_name | character |
Examples
try(mlb_schedule_event_types())
Find game_pk values for professional baseball games (major and minor leagues) that are tied
Description
Find game_pk values for professional baseball games (major and minor leagues) that are tied
Usage
mlb_schedule_games_tied(season = 2021, game_type = "S")
Arguments
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
|
Value
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 |
Examples
try(mlb_schedule_games_tied(season = 2021))
Find game_pk values for professional baseball postseason games (major and minor leagues)
Description
Find game_pk values for professional baseball postseason games (major and minor leagues)
Usage
mlb_schedule_postseason(
season = 2021,
game_type = NULL,
series_number = NULL,
sport_id = 1,
team_id = NULL
)
Arguments
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.
|
Value
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 |
Examples
try(mlb_schedule_postseason(season = 2021))
Find game_pk values for professional baseball postseason series games (major and minor leagues)
Description
Find game_pk values for professional baseball postseason series games (major and minor leagues)
Usage
mlb_schedule_postseason_series(
season = 2021,
game_type = NULL,
series_number = NULL,
sport_id = 1,
team_id = NULL
)
Arguments
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.
|
Value
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 |
Examples
try(mlb_schedule_postseason_series(season = 2021, sport_id = 1))
Find MLB Seasons
Description
Find MLB Seasons
Usage
mlb_seasons(sport_id = 1, with_game_type_dates = TRUE)
Arguments
sport_id |
The sport_id to return season information for. |
with_game_type_dates |
with_game_type_dates to return season information |
Value
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 |
Examples
try(mlb_seasons(sport_id = 1))
Find MLB Seasons all
Description
Find MLB Seasons all
Usage
mlb_seasons_all(
sport_id = 1,
division_id = NULL,
league_id = NULL,
with_game_type_dates = TRUE
)
Arguments
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. |
Value
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 |
Examples
try(mlb_seasons_all(sport_id = 1))
MLB Situation Codes
Description
MLB Situation Codes
Usage
mlb_situation_codes()
Value
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 |
Examples
try(mlb_situation_codes())
MLB Sky (Weather) Codes
Description
MLB Sky (Weather) Codes
Usage
mlb_sky()
Value
Returns a tibble with the following columns
col_name | types |
sky_code | character |
sky_description | character |
Examples
try(mlb_sky())
MLB Sport IDs
Description
MLB Sport IDs
Usage
mlb_sports(sport_id = NULL)
Arguments
sport_id |
The sport_id to return information for. |
Value
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 |
Examples
try(mlb_sports())
MLB Sport IDs Information
Description
MLB Sport IDs Information
Usage
mlb_sports_info(sport_id = 1)
Arguments
sport_id |
The sport_id to return information for. |
Value
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 |
Examples
try(mlb_sports_info(sport_id = 1))
MLB Sport Players
Description
MLB Sport Players
Usage
mlb_sports_players(sport_id = 1, season = 2021)
Arguments
sport_id |
The sport_id to return information for. |
season |
The season to return information for. |
Value
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 |
Examples
try(mlb_sports_players(sport_id = 1, season = 2021))
MLB Standings
Description
MLB Standings
Usage
mlb_standings(
season = NULL,
date = NULL,
standings_type = NULL,
league_id = NULL
)
Arguments
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. |
Value
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 |
Examples
try(mlb_standings(season = 2021, league_id = 103))
MLB Standings Types
Description
MLB Standings Types
Usage
mlb_standings_types()
Value
Returns a tibble with the following columns
col_name | types |
standings_type_name | character |
standings_type_description | character |
Examples
try(mlb_standings_types())
MLB Stat Groups
Description
MLB Stat Groups
Usage
mlb_stat_groups()
Value
Returns a tibble with the following columns
col_name | types |
stat_group_name | character |
Examples
try(mlb_stat_groups())
MLB Stat Types
Description
MLB Stat Types
Usage
mlb_stat_types()
Value
Returns a tibble with the following columns
col_name | types |
stat_type_name | character |
Examples
try(mlb_stat_types())
MLB Stats
Description
MLB Stats
Usage
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
)
Arguments
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. |
Value
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 |
Examples
try(mlb_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Stats Leaders
Description
MLB Stats Leaders
Usage
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
)
Arguments
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. |
Value
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 |
Examples
try(mlb_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
MLB Team Affiliates
Description
MLB Team Affiliates
Usage
mlb_team_affiliates(team_ids = NULL, sport_ids = NULL, season = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_affiliates(team_ids = 147))
MLB Team Alumni
Description
MLB Team Alumni
Usage
mlb_team_alumni(team_id = NULL, stat_group = NULL, season = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_alumni(team_id = 137, stat_group = 'hitting', season = 2021))
MLB Team Coaches
Description
MLB Team Coaches
Usage
mlb_team_coaches(team_id = NULL, date = NULL, season = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_coaches(team_id = 137, season = 2021))
MLB Teams History
Description
MLB Teams History
Usage
mlb_team_history(team_ids = NULL, start_season = NULL, end_season = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_history(team_ids = 147))
MLB Team Info
Description
MLB Team Info
Usage
mlb_team_info(team_id = NULL, season = NULL, sport_id = NULL)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_info(team_id = 147))
MLB Team Leaders
Description
MLB Team Leaders
Usage
mlb_team_leaders(
team_id = NULL,
leader_categories = NULL,
leader_game_types = NULL,
season = NULL,
limit = 1000
)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_leaders(team_id = 137, leader_categories = "homeRuns", season = 2021))
MLB Team Personnel
Description
MLB Team Personnel
Usage
mlb_team_personnel(team_id = NULL, date = NULL)
Arguments
team_id |
Team ID to return team coach information for. |
date |
Date to return team coach information for. |
Value
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 |
Examples
try(mlb_team_personnel(team_id = 137, date = "08/28/2016"))
MLB Team Individual Stats
Description
MLB Team Individual Stats
Usage
mlb_team_stats(
team_id = NULL,
stat_type = NULL,
game_type = NULL,
stat_group = NULL,
season = NULL,
sport_ids = NULL
)
Arguments
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. |
Value
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 |
Examples
try(mlb_team_stats(team_id = 137, stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Teams
Description
MLB Teams
Usage
mlb_teams(
season = NULL,
active_status = NULL,
all_star_statuses = NULL,
league_ids = NULL,
sport_ids = NULL,
game_type = NULL
)
Arguments
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. |
Value
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 |
Examples
try(mlb_teams(season = 2021, sport_ids = c(1)))
MLB Teams Stats
Description
MLB Teams Stats
Usage
mlb_teams_stats(
stat_type = NULL,
game_type = NULL,
stat_group = NULL,
season = NULL,
sport_ids = NULL,
sort_stat = NULL,
order = NULL
)
Arguments
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. |
Value
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 |
Examples
try(mlb_teams_stats(stat_type = 'season', stat_group = 'hitting', season = 2021))
MLB Teams Stats Leaders
Description
MLB Teams Stats Leaders
Usage
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
)
Arguments
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. |
Value
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 |
Examples
try(mlb_teams_stats_leaders(leader_categories='homeRuns',sport_id=1, season = 2021))
Find MLB Venues
Description
Find MLB Venues
Usage
mlb_venues(venue_ids = NULL, sport_ids = NULL, season = NULL)
Arguments
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. |
Value
Returns a tibble with the following columns:
col_name | types |
venue_id | integer |
venue_name | character |
venue_link | character |
active | logical |
season | logical |
Examples
try(mlb_venues())
try(mlb_venues(venue_ids = 4781))
try(mlb_venues(sport_ids = 1))
MLB Wind Direction Codes
Description
MLB Wind Direction Codes
Usage
mlb_wind_direction_codes()
Value
Returns a tibble with the following columns
col_name | types |
wind_direction_code | character |
wind_direction_description | character |
Examples
try(mlb_wind_direction_codes())
Most Recent MLB Season
Description
Most Recent MLB Season
Usage
most_recent_mlb_season()
Value
An integer indicating the year of the most recent season of Major League Baseball
Most Recent NCAA Baseball Season
Description
Most Recent NCAA Baseball Season
Usage
most_recent_ncaa_baseball_season()
Value
An integer indicating the year of the most recent season of NCAA baseball
NCAA Functions Overview
Description
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
Details
Scrape NCAA baseball data (Division I, II, and III)
ncaa_team_player_stats(team_id = 255, year = 2013, type = "batting")
Get Play-By-Play Data for NCAA Baseball Games
x <- ncaa_schedule_info(736, 2021)$game_info_url[2] ncaa_pbp(game_info_url = x)
Get NCAA Baseball Rosters
ncaa_roster(team_id = 104, year = 2021)
Get NCAA Baseball Game Logs
ncaa_game_logs(player_id = 2113782, year = 2021, type = "pitching", span = "game")
Get NCAA Baseball Game Lineups
ncaa_lineups(game_info_url="https://stats.ncaa.org/game/index/4587474?org_id=528",year=2018)
Get Park Effects for NCAA Baseball Teams
ncaa_park_factor(team_id = 736, years = c(2017:2019), type = "conference")
Get Schedule and Results for NCAA Baseball Teams
ncaa_schedule_info(team_id = 736, year = 2021)
Lookup NCAA School IDs (Division I, II, and III)
ncaa_school_id_lu("VAN")
Scrape NCAA baseball Teams (Division I, II, and III)
ncaa_teams(year = 2023, division = 1)
(legacy) Get NCAA Baseball Rosters
Description
(legacy) Get NCAA Baseball Rosters
(legacy) Get NCAA Baseball Rosters
Usage
ncaa_baseball_roster(team_id = NULL, year, ...)
get_ncaa_baseball_roster(team_id = NULL, year, ...)
Arguments
team_id |
NCAA id for a school |
year |
The year of interest |
... |
Additional arguments passed to an underlying function like httr. |
Value
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
Description
Get NCAA Baseball Game Logs
Usage
ncaa_game_logs(player_id, year, type = "batting", span = "game", ...)
Arguments
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. |
Value
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 |
Examples
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"))
Retrieve lineups for a given NCAA game via its game_info_url
Description
Retrieve lineups for a given NCAA game via its game_info_url
Usage
ncaa_lineups(game_info_url = NULL, ...)
Arguments
game_info_url |
The unique game info url |
... |
Additional arguments passed to an underlying function like httr. |
Value
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 |
Examples
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
Description
Get Park Effects for NCAA Baseball Teams
Usage
ncaa_park_factor(team_id, years, type = "conference", ...)
Arguments
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. |
Details
try(ncaa_park_factor(team_id = 736, years = c(2018:2019), type = "conference"))
Value
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
Description
Get Play-By-Play Data for NCAA Baseball Games
Usage
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_,
...
)
Arguments
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. |
Value
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 |
Examples
try(ncaa_pbp(game_info_url = "https://stats.ncaa.org/contests/2167178/box_score"))
Get NCAA Baseball Rosters
Description
Get NCAA Baseball Rosters
Usage
ncaa_roster(team_id = NULL, year, ...)
Arguments
team_id |
NCAA id for a school |
year |
The year of interest |
... |
Additional arguments passed to an underlying function like httr. |
Value
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 |
Examples
try(ncaa_roster(team_id = 104, year = 2023))
Get Schedule and Results for NCAA Baseball Teams
Description
Get Schedule and Results for NCAA Baseball Teams
Usage
ncaa_schedule_info(team_id = NULL, year = NULL, pbp_links = FALSE, ...)
Arguments
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. |
Details
try(ncaa_schedule_info(team_id = 736, year = 2019))
Value
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 |
Lookup NCAA baseball school IDs (Division I, II, and III)
Description
This function allows the user to look up the team_id
needed
for the ncaa_team_player_stats()
function.
Usage
ncaa_school_id_lu(team_name = NULL)
Arguments
team_name |
A string that will be searched for in the names of the teams. |
Value
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 |
Examples
try(ncaa_school_id_lu("Van"))
(legacy) Scrape NCAA baseball Team Player Stats (Division I, II, and III)
Description
(legacy) Scrape NCAA baseball Team Player Stats (Division I, II, and III)
Usage
ncaa_scrape(
team_id,
year = most_recent_ncaa_baseball_season(),
type = "batting",
...
)
Arguments
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. |
Value
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 |
Scrape NCAA baseball Team Player Stats (Division I, II, and III)
Description
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.
Usage
ncaa_team_player_stats(
team_id,
year = most_recent_ncaa_baseball_season(),
type = "batting",
...
)
Arguments
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. |
Value
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 |
Examples
try(ncaa_team_player_stats(team_id = 234, year = 2023, type = "batting"))
Scrape NCAA baseball Teams (Division I, II, and III)
Description
This function allows the user to obtain NCAA teams by year and division
Usage
ncaa_teams(year = most_recent_ncaa_baseball_season(), division = 1, ...)
Arguments
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. |
Details
ncaa_teams(2023, 1)
Value
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
Description
(legacy) Scrape Pitcher Game Logs from FanGraphs
Usage
pitcher_game_logs_fg(playerid, year)
Arguments
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) |
Value
A data frame of pitcher game logs.
Look up Baseball Player IDs by Player Name
Description
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.
Usage
playerid_lookup(last_name = NULL, first_name = NULL)
Arguments
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. |
Value
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 |
Examples
try(playerid_lookup("Garcia", "Karim"))
Look up Baseball Player Name by ID
Description
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.
Usage
playername_lookup(id)
Arguments
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. |
Value
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 |
Examples
try(playername_lookup(4885))
try(playername_lookup("kaaihki01"))
Process Baseball Savant CSV payload
Description
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
Usage
process_statcast_payload(payload)
Arguments
payload |
payload from a Baseball Savant request |
Value
A tibble with the processed Statcast data coerced to the correct types.
Progressively
Description
This function helps add progress-reporting to any function - given function f()
and progressor p()
, it will return a new function that calls f()
and then (on-exiting) will call p()
after every iteration.
This is inspired by purrr's safely
, quietly
, and possibly
function decorators.
Usage
progressively(f, p = NULL)
Arguments
f |
a function to add progressr functionality to. |
p |
a progressor function as created by |
Value
a function that does the same as f
but it calls p()
after iteration.
Load .rds file from a remote connection
Description
Load .rds file from a remote connection
Usage
rds_from_url(url)
Arguments
url |
a character url |
Value
a dataframe as created by readRDS()
Retry http request with proxy
Description
This is a thin wrapper on httr::RETRY
Usage
request_with_proxy(url, ...)
Arguments
url |
Request url |
... |
passed to httr::RETRY |
Get, Parse, and Format Retrosheet Event and Roster Files
Description
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.
Usage
retrosheet_data(
path_to_directory = NULL,
years_to_acquire = most_recent_mlb_season() - 1,
sequence_years = FALSE
)
Arguments
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. |
Details
retrosheet_data(path_to_directory = NULL, years_to_acquire = most_recent_mlb_season()-1, sequence_years = FALSE)
Value
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
Generate run expectancy and related measures from Baseball Savant data
Description
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.
Usage
run_expectancy_code(df, level = "plate appearance")
Arguments
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. |
Value
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 |
Examples
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)
Description
(legacy) Lookup NCAA baseball school IDs (Division I, II, and III)
Usage
school_id_lu(team_name = NULL)
Arguments
team_name |
A string that will be searched for in the names of the teams. |
Value
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
Description
(legacy) Query Baseball Savant Leaderboards
Usage
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 = ""
)
Arguments
leaderboard |
The type of leaderboard to retrieve, input as a string. Current options include exit_velocity_barrels, expected_statistics, pitch_arsenal, outs_above_average, directional_oaa, catch_probability, pop_time, sprint_speed, and running_splits_90_ft, 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. |
Value
Returns a tibble of Statcast leaderboard data.
(legacy) Query Statcast by Date Range and Players
Description
(legacy) Query Statcast by Date Range and Players
Usage
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, ...)
Arguments
start_date |
Date of first game for which you want data. Format must be in YYYY-MM-DD format. |
end_date |
Date of last game for which you want data. Format must be in YYYY-MM-DD format. |
playerid |
The MLBAM ID for the player whose data you want to query. |
player_type |
The player type. Can be |
... |
currently ignored |
batterid |
The MLBAM ID for the batter whose data you want to query. |
pitcherid |
The MLBAM ID for the pitcher whose data you want to query. |
Value
Returns a tibble with Statcast data.
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.
Scrape League Payroll Breakdowns from Spotrac
Description
This function allows you to scrape each team's payroll from Spotrac.
Usage
sptrc_league_payrolls(year = most_recent_mlb_season())
Arguments
year |
Year to load |
Value
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 |
Examples
try(sptrc_league_payrolls(year = most_recent_mlb_season()))
Scrape Team Active Payroll Breakdown from Spotrac
Description
This function allows you to scrape a team's active payroll from Spotrac.
Usage
sptrc_team_active_payroll(team_abbr, year = most_recent_mlb_season())
Arguments
team_abbr |
Team abbreviation |
year |
Year to load |
Value
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 |
Examples
try(sptrc_team_active_payroll(team_abbr = "BAL", year = most_recent_mlb_season()))
(legacy) Scrape MLB Standings on a Given Date
Description
(legacy) Scrape MLB Standings on a Given Date
Usage
standings_on_date_bref(date, division, from = FALSE)
Arguments
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 |
Value
Returns a tibble of MLB standings
Statcast Functions Overview
Description
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.
Details
Query Statcast Batters by Date Range
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)
Query Statcast Pitchers by Date Range
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)
Query Statcast Batters by Date Range and Player ID
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)
Query Statcast Pitchers by Date Range and Player ID
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)
Query Baseball Savant Leaderboards
statcast_leaderboards(leaderboard = "exit_velocity_barrels", year = 2021)
Statcast Label Imputation
Description
Statcast Label Imputation
Usage
statcast_impute
Format
An object of class data.frame
with 44 rows and 4 columns.
Query Baseball Savant Leaderboards
Description
This function allows you to read leaderboard data from BaseballSavant directly into R as data frame.
Usage
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 = ""
)
Arguments
leaderboard |
The type of leaderboard to retrieve, input as a string. Current options include exit_velocity_barrels, expected_statistics, pitch_arsenal, outs_above_average, directional_oaa, catch_probability, pop_time, sprint_speed, and running_splits_90_ft, 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. |
Details
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
Value
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 |
Examples
try(statcast_leaderboards(leaderboard = "expected_statistics", year = 2018))
try(statcast_leaderboards(leaderboard = "arm_strength", year = 2020))
Query Statcast by Date Range and Players
Description
This function allows you to query Statcast data as provided on https://baseballsavant.mlb.com
Usage
statcast_search(
start_date = Sys.Date() - 1,
end_date = Sys.Date(),
playerid = NULL,
player_type = "batter",
...
)
statcast_search.default(
start_date = Sys.Date() - 1,
end_date = Sys.Date(),
playerid = NULL,
player_type = "batter",
...
)
statcast_search_batters(start_date, end_date, batterid = NULL, ...)
statcast_search_pitchers(start_date, end_date, pitcherid = NULL, ...)
Arguments
start_date |
Date of first game for which you want data. Format must be in YYYY-MM-DD format. |
end_date |
Date of last game for which you want data. Format must be in YYYY-MM-DD format. |
playerid |
The MLBAM ID for the player whose data you want to query. |
player_type |
The player type. Can be |
... |
currently ignored |
batterid |
The MLBAM ID for the batter whose data you want to query. |
pitcherid |
The MLBAM ID for the pitcher whose data you want to query. |
Value
Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Returns a tibble with Statcast data.
Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Returns a tibble with Statcast data with the following columns:
col_name | types |
pitch_type | character |
game_date | Date |
release_speed | numeric |
release_pos_x | numeric |
release_pos_z | numeric |
player_name | character |
batter | numeric |
pitcher | numeric |
events | character |
description | character |
spin_dir | logical |
spin_rate_deprecated | logical |
break_angle_deprecated | logical |
break_length_deprecated | logical |
zone | numeric |
des | character |
game_type | character |
stand | character |
p_throws | character |
home_team | character |
away_team | character |
type | character |
hit_location | integer |
bb_type | character |
balls | integer |
strikes | integer |
game_year | integer |
pfx_x | numeric |
pfx_z | numeric |
plate_x | numeric |
plate_z | numeric |
on_3b | numeric |
on_2b | numeric |
on_1b | numeric |
outs_when_up | integer |
inning | numeric |
inning_topbot | character |
hc_x | numeric |
hc_y | numeric |
tfs_deprecated | logical |
tfs_zulu_deprecated | logical |
fielder_2 | numeric |
umpire | logical |
sv_id | character |
vx0 | numeric |
vy0 | numeric |
vz0 | numeric |
ax | numeric |
ay | numeric |
az | numeric |
sz_top | numeric |
sz_bot | numeric |
hit_distance_sc | numeric |
launch_speed | numeric |
launch_angle | numeric |
effective_speed | numeric |
release_spin_rate | numeric |
release_extension | numeric |
game_pk | numeric |
pitcher_1 | numeric |
fielder_2_1 | numeric |
fielder_3 | numeric |
fielder_4 | numeric |
fielder_5 | numeric |
fielder_6 | numeric |
fielder_7 | numeric |
fielder_8 | numeric |
fielder_9 | numeric |
release_pos_y | numeric |
estimated_ba_using_speedangle | numeric |
estimated_woba_using_speedangle | numeric |
woba_value | numeric |
woba_denom | integer |
babip_value | integer |
iso_value | integer |
launch_speed_angle | integer |
at_bat_number | numeric |
pitch_number | numeric |
pitch_name | character |
home_score | numeric |
away_score | numeric |
bat_score | numeric |
fld_score | numeric |
post_away_score | numeric |
post_home_score | numeric |
post_bat_score | numeric |
post_fld_score | numeric |
if_fielding_alignment | character |
of_fielding_alignment | character |
spin_axis | numeric |
delta_home_win_exp | numeric |
delta_run_exp | numeric |
Examples
### 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)
})
Create stat lines from Statcast data
Description
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.
Usage
statline_from_statcast(df, base = "pa")
Arguments
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". |
Details
statline_from_statcast(df, base = "contact")
Value
A tibble with the additional columns calculated using the Statcast data.
Column structure of MLB Stats Live Game API data frame
Description
An empty tibble
Usage
stats_api_live_empty_df
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 0 rows and 131 columns.
Calculate Team-level Consistency
Description
This function allows you to calculate team-level consistency in run scoring and run prevention over the course of an entire season.
Usage
team_consistency(year)
Arguments
year |
Season consistency should be run for. |
Details
try(team_consistency(year=2021))
Value
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
Description
(legacy) Scrape Team Results
Usage
team_results_bref(Tm, year)
Arguments
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. |
Value
Returns a tibble of MLB team results
A Team Lookup Table
Description
A Team Lookup Table
Usage
teams_lu_table
Format
An object of class data.frame
with 797 rows and 31 columns.
Calculate wOBA and related metrics for any set of data
Description
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.
Usage
woba_plus(df)
Arguments
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. |
Value
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 |
Examples
try({
df <- bref_daily_batter("2015-08-01", "2015-10-03")
woba_plus(df)
})