Skip to contents

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_nametypes
Seasoninteger
team_namecharacter
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
Relievingnumeric
Relief_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
CH_pctnumeric
CHvnumeric
SF_pctnumeric
SFvnumeric
XX_pctnumeric
wFBnumeric
wSLnumeric
wCTnumeric
wCBnumeric
wCHnumeric
wSFnumeric
wFB_Cnumeric
wSL_Cnumeric
wCT_Cnumeric
wCB_Cnumeric
wCH_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
rFTeamVinteger
rBTeamVinteger
rTVinteger
pfx_FA_pctnumeric
pfx_FT_pctnumeric
pfx_FC_pctnumeric
pfx_FS_pctnumeric
pfx_SI_pctnumeric
pfx_SL_pctnumeric
pfx_CU_pctnumeric
pfx_KC_pctnumeric
pfx_CH_pctnumeric
pfx_vFAnumeric
pfx_vFTnumeric
pfx_vFCnumeric
pfx_vFSnumeric
pfx_vSInumeric
pfx_vSLnumeric
pfx_vCUnumeric
pfx_vKCnumeric
pfx_vCHnumeric
pfx_FA-Xnumeric
pfx_FT-Xnumeric
pfx_FC-Xnumeric
pfx_FS-Xnumeric
pfx_SI-Xnumeric
pfx_SL-Xnumeric
pfx_CU-Xnumeric
pfx_KC-Xnumeric
pfx_CH-Xnumeric
pfx_FA-Znumeric
pfx_FT-Znumeric
pfx_FC-Znumeric
pfx_FS-Znumeric
pfx_SI-Znumeric
pfx_SL-Znumeric
pfx_CU-Znumeric
pfx_KC-Znumeric
pfx_CH-Znumeric
pfx_wFAnumeric
pfx_wFTnumeric
pfx_wFCnumeric
pfx_wFSnumeric
pfx_wSInumeric
pfx_wSLnumeric
pfx_wCUnumeric
pfx_wKCnumeric
pfx_wCHnumeric
pfx_wFA_Cnumeric
pfx_wFT_Cnumeric
pfx_wFC_Cnumeric
pfx_wFS_Cnumeric
pfx_wSI_Cnumeric
pfx_wSL_Cnumeric
pfx_wCU_Cnumeric
pfx_wKC_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_FC_pctnumeric
pi_FS_pctnumeric
pi_SI_pctnumeric
pi_SL_pctnumeric
pi_XX_pctnumeric
pi_vCHnumeric
pi_vCUnumeric
pi_vFAnumeric
pi_vFCnumeric
pi_vFSnumeric
pi_vSInumeric
pi_vSLnumeric
pi_vXXnumeric
pi_CH-Xnumeric
pi_CU-Xnumeric
pi_FA-Xnumeric
pi_FC-Xnumeric
pi_FS-Xnumeric
pi_SI-Xnumeric
pi_SL-Xnumeric
pi_XX-Xnumeric
pi_CH-Znumeric
pi_CU-Znumeric
pi_FA-Znumeric
pi_FC-Znumeric
pi_FS-Znumeric
pi_SI-Znumeric
pi_SL-Znumeric
pi_XX-Znumeric
pi_wCHnumeric
pi_wCUnumeric
pi_wFAnumeric
pi_wFCnumeric
pi_wFSnumeric
pi_wSInumeric
pi_wSLnumeric
pi_wXXnumeric
pi_wCH_Cnumeric
pi_wCU_Cnumeric
pi_wFA_Cnumeric
pi_wFC_Cnumeric
pi_wFS_Cnumeric
pi_wSI_Cnumeric
pi_wSL_Cnumeric
pi_wXX_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
pfx_EP_pctnumeric
pfx_vEPnumeric
pfx_EP-Xnumeric
pfx_EP-Znumeric
pfx_wEPnumeric
pfx_wEP_Cnumeric
pi_SB_pctnumeric
pi_vSBnumeric
pi_SB-Xnumeric
pi_SB-Znumeric
pi_wSBnumeric
pi_wSB_Cnumeric
pi_CS_pctnumeric
pi_vCSnumeric
pi_CS-Xnumeric
pi_CS-Znumeric
pi_wCSnumeric
pi_wCS_Cnumeric
pi_KN_pctnumeric
pi_vKNnumeric
pi_KN-Xnumeric
pi_KN-Znumeric
pi_wKNnumeric
pi_wKN_Cnumeric
KN_pctnumeric
KNvnumeric
wKNnumeric
wKN_Cnumeric
pfx_KN_pctnumeric
pfx_vKNnumeric
pfx_KN-Xnumeric
pfx_KN-Znumeric
pfx_wKNnumeric
pfx_wKN_Cnumeric
pfx_SC_pctnumeric
pfx_vSCnumeric
pfx_SC-Xnumeric
pfx_SC-Znumeric
pfx_wSCnumeric
pfx_wSC_Cnumeric
pfx_FO_pctnumeric
pfx_vFOnumeric
pfx_FO-Xnumeric
pfx_FO-Znumeric
pfx_wFOnumeric
pfx_wFO_Cnumeric

Examples

# \donttest{
  try(fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150))
#> ── MLB Team Pitching data from FanGraphs.com ──────── baseballr 1.6.0 ──
#>  Data updated: 2024-04-13 21:55:10 UTC
#> # A tibble: 30 × 346
#>    Season team_name SeasonMin SeasonMax     W     L   ERA     G    GS
#>     <int> <chr>         <int>     <int> <int> <int> <dbl> <int> <int>
#>  1   2015 CHC            2015      2015    97    65  3.36   714   162
#>  2   2015 WSN            2015      2015    83    79  3.62   630   162
#>  3   2015 CLE            2015      2015    81    80  3.68   637   161
#>  4   2015 STL            2015      2015   100    62  2.94   677   162
#>  5   2015 LAD            2015      2015    92    70  3.46   677   162
#>  6   2015 PIT            2015      2015    98    64  3.23   662   162
#>  7   2015 NYM            2015      2015    90    72  3.45   647   162
#>  8   2015 HOU            2015      2015    86    76  3.57   644   162
#>  9   2015 NYY            2015      2015    87    75  4.03   659   162
#> 10   2015 CHW            2015      2015    76    86  3.98   576   162
#> # ℹ 20 more rows
#> # ℹ 337 more variables: QS <int>, CG <int>, ShO <int>, SV <int>,
#> #   BS <int>, IP <dbl>, TBF <int>, H <int>, R <int>, ER <int>,
#> #   HR <int>, BB <int>, IBB <int>, HBP <int>, WP <int>, BK <int>,
#> #   SO <int>, GB <int>, FB <int>, LD <int>, IFFB <int>, Pitches <int>,
#> #   Balls <int>, Strikes <int>, RS <int>, IFH <int>, BU <int>,
#> #   BUH <int>, K_9 <dbl>, BB_9 <dbl>, K_BB <dbl>, H_9 <dbl>, …
# }