Skip to contents

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_nametypes
Seasoninteger
team_namecharacter
Throwscharacter
xMLBAMIDinteger
PlayerNameRoutecharacter
PlayerNamecharacter
playeridinteger
Ageinteger
AgeRngcharacter
SeasonMininteger
SeasonMaxinteger
Winteger
Linteger
ERAnumeric
Ginteger
GSinteger
CGinteger
ShOinteger
SVinteger
BSinteger
IPnumeric
TBFinteger
Hinteger
Rinteger
ERinteger
HRinteger
BBinteger
IBBinteger
HBPinteger
WPinteger
BKinteger
SOinteger
GBinteger
FBinteger
LDinteger
IFFBinteger
Pitchesinteger
Ballsinteger
Strikesinteger
RSinteger
IFHinteger
BUinteger
BUHinteger
K_9numeric
BB_9numeric
K_BBnumeric
H_9numeric
HR_9numeric
AVGnumeric
WHIPnumeric
BABIPnumeric
LOB_pctnumeric
FIPnumeric
GB_FBnumeric
LD_pctnumeric
GB_pctnumeric
FB_pctnumeric
IFFB_pctnumeric
HR_FBnumeric
IFH_pctnumeric
BUH_pctnumeric
TTO_pctnumeric
CFramingnumeric
Startingnumeric
Start_IPnumeric
RARnumeric
WARnumeric
Dollarsnumeric
RA9-Winsnumeric
LOB-Winsnumeric
BIP-Winsnumeric
BS-Winsnumeric
tERAnumeric
xFIPnumeric
WPAnumeric
WPA_minusnumeric
WPA_plusnumeric
RE24numeric
REWnumeric
pLInumeric
inLInumeric
gmLInumeric
exLInumeric
Pullsinteger
Gamesinteger
WPA_LInumeric
Clutchnumeric
FBall_pctnumeric
FBvnumeric
SL_pctnumeric
SLvnumeric
CT_pctnumeric
CTvnumeric
CB_pctnumeric
CBvnumeric
SF_pctnumeric
SFvnumeric
XX_pctnumeric
wFBnumeric
wSLnumeric
wCTnumeric
wCBnumeric
wSFnumeric
wFB_Cnumeric
wSL_Cnumeric
wCT_Cnumeric
wCB_Cnumeric
wSF_Cnumeric
O-Swing_pctnumeric
Z-Swing_pctnumeric
Swing_pctnumeric
O-Contact_pctnumeric
Z-Contact_pctnumeric
Contact_pctnumeric
Zone_pctnumeric
F-Strike_pctnumeric
SwStr_pctnumeric
CStr_pctnumeric
C+SwStr_pctnumeric
HLDinteger
SDinteger
MDinteger
ERA-numeric
FIP-numeric
xFIP-numeric
K_pctnumeric
BB_pctnumeric
K-BB_pctnumeric
SIERAnumeric
kwERAnumeric
RS_9numeric
E-Fnumeric
Pullinteger
Centinteger
Oppointeger
Softinteger
Medinteger
Hardinteger
bipCountinteger
Pull_pctnumeric
Cent_pctnumeric
Oppo_pctnumeric
Soft_pctnumeric
Med_pctnumeric
Hard_pctnumeric
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
xERAnumeric
pb_o_CHnumeric
pb_s_CHnumeric
pb_c_CHnumeric
pb_o_CUnumeric
pb_s_CUnumeric
pb_c_CUnumeric
pb_o_FFnumeric
pb_s_FFnumeric
pb_c_FFnumeric
pb_o_SInumeric
pb_s_SInumeric
pb_c_SInumeric
pb_o_SLnumeric
pb_s_SLnumeric
pb_c_SLnumeric
pb_overallnumeric
pb_stuffnumeric
pb_commandnumeric
pb_xRV100numeric
pb_ERAnumeric
sp_s_CHnumeric
sp_l_CHnumeric
sp_p_CHnumeric
sp_s_CUnumeric
sp_l_CUnumeric
sp_p_CUnumeric
sp_s_FFnumeric
sp_l_FFnumeric
sp_p_FFnumeric
sp_s_SInumeric
sp_l_SInumeric
sp_p_SInumeric
sp_s_SLnumeric
sp_l_SLnumeric
sp_p_SLnumeric
sp_stuffnumeric
sp_locationnumeric
sp_pitchingnumeric
PPTVinteger
CPTVinteger
BPTVinteger
DSVinteger
DGVinteger
BTVinteger
rPPTVnumeric
rBPTVnumeric
EBVinteger
ESVinteger
rFTeamVnumeric
rBTeamVnumeric
rTVnumeric
pfx_FA_pctnumeric
pfx_SI_pctnumeric
pfx_SL_pctnumeric
pfx_CU_pctnumeric
pfx_CH_pctnumeric
pfx_vFAnumeric
pfx_vSInumeric
pfx_vSLnumeric
pfx_vCUnumeric
pfx_vCHnumeric
pfx_FA-Xnumeric
pfx_SI-Xnumeric
pfx_SL-Xnumeric
pfx_CU-Xnumeric
pfx_CH-Xnumeric
pfx_FA-Znumeric
pfx_SI-Znumeric
pfx_SL-Znumeric
pfx_CU-Znumeric
pfx_CH-Znumeric
pfx_wFAnumeric
pfx_wSInumeric
pfx_wSLnumeric
pfx_wCUnumeric
pfx_wCHnumeric
pfx_wFA_Cnumeric
pfx_wSI_Cnumeric
pfx_wSL_Cnumeric
pfx_wCU_Cnumeric
pfx_wCH_Cnumeric
pfx_O-Swing_pctnumeric
pfx_Z-Swing_pctnumeric
pfx_Swing_pctnumeric
pfx_O-Contact_pctnumeric
pfx_Z-Contact_pctnumeric
pfx_Contact_pctnumeric
pfx_Zone_pctnumeric
pfx_Pacenumeric
pi_CH_pctnumeric
pi_CU_pctnumeric
pi_FA_pctnumeric
pi_SI_pctnumeric
pi_SL_pctnumeric
pi_vCHnumeric
pi_vCUnumeric
pi_vFAnumeric
pi_vSInumeric
pi_vSLnumeric
pi_CH-Xnumeric
pi_CU-Xnumeric
pi_FA-Xnumeric
pi_SI-Xnumeric
pi_SL-Xnumeric
pi_CH-Znumeric
pi_CU-Znumeric
pi_FA-Znumeric
pi_SI-Znumeric
pi_SL-Znumeric
pi_wCHnumeric
pi_wCUnumeric
pi_wFAnumeric
pi_wSInumeric
pi_wSLnumeric
pi_wCH_Cnumeric
pi_wCU_Cnumeric
pi_wFA_Cnumeric
pi_wSI_Cnumeric
pi_wSL_Cnumeric
pi_O-Swing_pctnumeric
pi_Z-Swing_pctnumeric
pi_Swing_pctnumeric
pi_O-Contact_pctnumeric
pi_Z-Contact_pctnumeric
pi_Contact_pctnumeric
pi_Zone_pctnumeric
pi_Pacenumeric
Eventsinteger
EVnumeric
LAnumeric
Barrelsinteger
Barrel_pctnumeric
maxEVnumeric
HardHitinteger
HardHit_pctnumeric
Qnumeric
TGinteger
TIPnumeric
team_name_abbcharacter
teamidinteger
CH_pctnumeric
CHvnumeric
wCHnumeric
wCH_Cnumeric
pb_o_FSnumeric
pb_s_FSnumeric
pb_c_FSnumeric
sp_s_FSnumeric
sp_l_FSnumeric
sp_p_FSnumeric
pfx_FS_pctnumeric
pfx_vFSnumeric
pfx_FS-Xnumeric
pfx_FS-Znumeric
pfx_wFSnumeric
pfx_wFS_Cnumeric
pi_FS_pctnumeric
pi_vFSnumeric
pi_FS-Xnumeric
pi_FS-Znumeric
pi_wFSnumeric
pi_wFS_Cnumeric
pb_o_FCnumeric
pb_s_FCnumeric
pb_c_FCnumeric
sp_s_FCnumeric
sp_l_FCnumeric
sp_p_FCnumeric
pfx_FC_pctnumeric
pfx_vFCnumeric
pfx_FC-Xnumeric
pfx_FC-Znumeric
pfx_wFCnumeric
pfx_wFC_Cnumeric
pi_FC_pctnumeric
pi_vFCnumeric
pi_FC-Xnumeric
pi_FC-Znumeric
pi_wFCnumeric
pi_wFC_Cnumeric
pb_o_KCnumeric
pb_s_KCnumeric
pb_c_KCnumeric
sp_s_KCnumeric
sp_l_KCnumeric
sp_p_KCnumeric
rBTVnumeric
pfx_KC_pctnumeric
pfx_vKCnumeric
pfx_KC-Xnumeric
pfx_KC-Znumeric
pfx_wKCnumeric
pfx_wKC_Cnumeric
rCPTVnumeric
KN_pctnumeric
KNvnumeric
wKNnumeric
wKN_Cnumeric
pfx_KN_pctnumeric
pfx_vKNnumeric
pfx_KN-Xnumeric
pfx_KN-Znumeric
pfx_wKNnumeric
pfx_wKN_Cnumeric
pi_KN_pctnumeric
pi_XX_pctnumeric
pi_vKNnumeric
pi_vXXnumeric
pi_KN-Xnumeric
pi_XX-Xnumeric
pi_KN-Znumeric
pi_XX-Znumeric
pi_wKNnumeric
pi_wXXnumeric
pi_wKN_Cnumeric
pi_wXX_Cnumeric
sp_s_FOnumeric
sp_l_FOnumeric
sp_p_FOnumeric
pfx_FO_pctnumeric
pfx_vFOnumeric
pfx_FO-Xnumeric
pfx_FO-Znumeric
pfx_wFOnumeric
pfx_wFO_Cnumeric
rDGVnumeric
pi_CS_pctnumeric
pi_vCSnumeric
pi_CS-Xnumeric
pi_CS-Znumeric
pi_wCSnumeric
pi_wCS_Cnumeric
Relievingnumeric
Relief_IPnumeric
rDSVnumeric
pfx_EP_pctnumeric
pfx_vEPnumeric
pfx_EP-Xnumeric
pfx_EP-Znumeric
pfx_wEPnumeric
pfx_wEP_Cnumeric
pfx_SC_pctnumeric
pfx_vSCnumeric
pfx_SC-Xnumeric
pfx_SC-Znumeric
pfx_wSCnumeric
pfx_wSC_Cnumeric
pi_SB_pctnumeric
pi_vSBnumeric
pi_SB-Xnumeric
pi_SB-Znumeric
pi_wSBnumeric
pi_wSB_Cnumeric

Examples

# \donttest{
  try(fg_pitcher_leaders(startseason = 2023, endseason = 2023))
#> 2024-04-13 21:55:09.488319: Invalid arguments or no player pitching leaders data available!
#> Error in fg_pitcher_leaders(startseason = 2023, endseason = 2023) : 
#>   object 'leaders' not found
# }