Skip to contents

Scrape Pitcher Leaderboards from FanGraphs

Usage

fg_pitcher_leaders(
  x,
  y,
  league = "all",
  qual = "y",
  pitcher_type = "pit",
  ind = 1
)

Arguments

x

First season for which you want data.

y

Last season for which you want data. If multiple years selected, data returned will be aggregate data for the date range. If y = x, function will return single-season data.

league

Option for limiting results to different leagues or overall results. Options are "al", "nl", or "all".

qual

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".

pitcher_type

Whether you want only starting pitchers, relievers, or all pitchers that meet the criteria specified in the qual argument. Options include "pit", "sta", "rel".

ind

Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons.

Value

A data frame of pitcher data.

col_nametypes
playeridcharacter
#character
Seasoncharacter
Namecharacter
Teamcharacter
Agenumeric
Wnumeric
Lnumeric
ERAnumeric
Gnumeric
GSnumeric
CGnumeric
ShOnumeric
SVnumeric
BSnumeric
IPnumeric
TBFnumeric
Hnumeric
Rnumeric
ERnumeric
HRnumeric
BBnumeric
IBBnumeric
HBPnumeric
WPnumeric
BKnumeric
SOnumeric
GBnumeric
FBnumeric
LDnumeric
IFFBnumeric
Ballsnumeric
Strikesnumeric
Pitchesnumeric
RSnumeric
IFHnumeric
BUnumeric
BUHnumeric
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
Startingnumeric
Start_IPnumeric
Relievingnumeric
Relief_IPnumeric
RARnumeric
WARnumeric
Dollarsnumeric
tERAnumeric
xFIPnumeric
WPAnumeric
WPA_minusnumeric
WPA_plusnumeric
RE24numeric
REWnumeric
pLInumeric
inLInumeric
gmLInumeric
exLInumeric
Pullsnumeric
WPA_LInumeric
Clutchnumeric
FBall_pctnumeric
FBvnumeric
SL_pctnumeric
SLvnumeric
CT_pctnumeric
CTvnumeric
CB_pctnumeric
CBvnumeric
CH_pctnumeric
CHvnumeric
SF_pctnumeric
SFvnumeric
KN_pctnumeric
KNvnumeric
XX_pctnumeric
PO_pctnumeric
wFBnumeric
wSLnumeric
wCTnumeric
wCBnumeric
wCHnumeric
wSFnumeric
wKNnumeric
wFB_Cnumeric
wSL_Cnumeric
wCT_Cnumeric
wCB_Cnumeric
wCH_Cnumeric
wSF_Cnumeric
wKN_Cnumeric
O-Swing_pctnumeric
Z-Swing_pctnumeric
Swing_pctnumeric
O-Contact_pctnumeric
Z-Contact_pctnumeric
Contact_pctnumeric
Zone_pctnumeric
F-Strike_pctnumeric
SwStr_pctnumeric
HLDnumeric
SDnumeric
MDnumeric
ERA-numeric
FIP-numeric
xFIP-numeric
K_pctnumeric
BB_pctnumeric
SIERAnumeric
RS_9numeric
E-Fnumeric
FA_pct (sc)numeric
FT_pct (sc)numeric
FC_pct (sc)numeric
FS_pct (sc)numeric
FO_pct (sc)numeric
SI_pct (sc)numeric
SL_pct (sc)numeric
CU_pct (sc)numeric
KC_pct (sc)numeric
EP_pct (sc)numeric
CH_pct (sc)numeric
SC_pct (sc)numeric
KN_pct (sc)numeric
UN_pct (sc)numeric
vFA (sc)numeric
vFT (sc)numeric
vFC (sc)numeric
vFS (sc)numeric
vFO (sc)numeric
vSI (sc)numeric
vSL (sc)numeric
vCU (sc)numeric
vKC (sc)numeric
vEP (sc)numeric
vCH (sc)numeric
vSC (sc)numeric
vKN (sc)numeric
FA-X (sc)numeric
FT-X (sc)numeric
FC-X (sc)numeric
FS-X (sc)numeric
FO-X (sc)numeric
SI-X (sc)numeric
SL-X (sc)numeric
CU-X (sc)numeric
KC-X (sc)numeric
EP-X (sc)numeric
CH-X (sc)numeric
SC-X (sc)numeric
KN-X (sc)numeric
FA-Z (sc)numeric
FT-Z (sc)numeric
FC-Z (sc)numeric
FS-Z (sc)numeric
FO-Z (sc)numeric
SI-Z (sc)numeric
SL-Z (sc)numeric
CU-Z (sc)numeric
KC-Z (sc)numeric
EP-Z (sc)numeric
CH-Z (sc)numeric
SC-Z (sc)numeric
KN-Z (sc)numeric
wFA (sc)numeric
wFT (sc)numeric
wFC (sc)numeric
wFS (sc)numeric
wFO (sc)numeric
wSI (sc)numeric
wSL (sc)numeric
wCU (sc)numeric
wKC (sc)numeric
wEP (sc)numeric
wCH (sc)numeric
wSC (sc)numeric
wKN (sc)numeric
wFA_C (sc)numeric
wFT_C (sc)numeric
wFC_C (sc)numeric
wFS_C (sc)numeric
wFO_C (sc)numeric
wSI_C (sc)numeric
wSL_C (sc)numeric
wCU_C (sc)numeric
wKC_C (sc)numeric
wEP_C (sc)numeric
wCH_C (sc)numeric
wSC_C (sc)numeric
wKN_C (sc)numeric
O-Swing_pct (sc)numeric
Z-Swing_pct (sc)numeric
Swing_pct (sc)numeric
O-Contact_pct (sc)numeric
Z-Contact_pct (sc)numeric
Contact_pct (sc)numeric
Zone_pct (sc)numeric
Pacenumeric
RA9-WARnumeric
BIP-Winsnumeric
LOB-Winsnumeric
FDP-Winsnumeric
AgeRngnumeric
K-BB_pctnumeric
Pull_pctnumeric
Cent_pctnumeric
Oppo_pctnumeric
Soft_pctnumeric
Med_pctnumeric
Hard_pctnumeric
kwERAnumeric
TTO_pctnumeric
CH_pct_pinumeric
CS_pct_pinumeric
CU_pct_pinumeric
FA_pct_pinumeric
FC_pct_pinumeric
FS_pct_pinumeric
KN_pct_pinumeric
SB_pct_pinumeric
SI_pct_pinumeric
SL_pct_pinumeric
XX_pct_pinumeric
vCH_pinumeric
vCS_pinumeric
vCU_pinumeric
vFA_pinumeric
vFC_pinumeric
vFS_pinumeric
vKN_pinumeric
vSB_pinumeric
vSI_pinumeric
vSL_pinumeric
vXX_pinumeric
CH-X_pinumeric
CS-X_pinumeric
CU-X_pinumeric
FA-X_pinumeric
FC-X_pinumeric
FS-X_pinumeric
KN-X_pinumeric
SB-X_pinumeric
SI-X_pinumeric
SL-X_pinumeric
XX-X_pinumeric
CH-Z_pinumeric
CS-Z_pinumeric
CU-Z_pinumeric
FA-Z_pinumeric
FC-Z_pinumeric
FS-Z_pinumeric
KN-Z_pinumeric
SB-Z_pinumeric
SI-Z_pinumeric
SL-Z_pinumeric
XX-Z_pinumeric
wCH_pinumeric
wCS_pinumeric
wCU_pinumeric
wFA_pinumeric
wFC_pinumeric
wFS_pinumeric
wKN_pinumeric
wSB_pinumeric
wSI_pinumeric
wSL_pinumeric
wXX_pinumeric
wCH_C_pinumeric
wCS_C_pinumeric
wCU_C_pinumeric
wFA_C_pinumeric
wFC_C_pinumeric
wFS_C_pinumeric
wKN_C_pinumeric
wSB_C_pinumeric
wSI_C_pinumeric
wSL_C_pinumeric
wXX_C_pinumeric
O-Swing_pct_pinumeric
Z-Swing_pct_pinumeric
Swing_pct_pinumeric
O-Contact_pct_pinumeric
Z-Contact_pct_pinumeric
Contact_pct_pinumeric
Zone_pct_pinumeric
Pace_pinumeric
Dolnumeric

Examples

# \donttest{
  fg_pitcher_leaders(x = 2015, y = 2015, qual = 150)
#> ── MLB Pitcher Leaders data from FanGraphs.com ────── baseballr 1.2.0 ──
#>  Data updated: 2022-04-30 07:15:20 UTC
#> # A tibble: 89 × 303
#>    playerid `#`   Season Name  Team    Age     W     L   ERA     G    GS
#>    <chr>    <chr> <chr>  <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1 1943     1     2015   Zack… LAD      31    19     3  1.66    32    32
#>  2 4153     2     2015   Jake… CHC      29    22     6  1.77    33    33
#>  3 2036     3     2015   Clay… LAD      27    16     7  2.13    33    33
#>  4 3184     4     2015   Davi… - - -    29    18     5  2.45    32    32
#>  5 9434     5     2015   Dall… HOU      27    20     8  2.48    33    33
#>  6 10954    6     2015   Jaco… NYM      27    14     8  2.54    30    30
#>  7 13125    7     2015   Gerr… PIT      24    19     8  2.6     32    32
#>  8 11713    8     2015   Matt… NYM      26    13     8  2.71    29    29
#>  9 12768    9     2015   Sonn… OAK      25    14     7  2.73    31    31
#> 10 1507     10    2015   John… STL      36    13    10  2.77    33    33
#> # … with 79 more rows, and 292 more variables: CG <dbl>, ShO <dbl>,
#> #   SV <dbl>, BS <dbl>, IP <dbl>, TBF <dbl>, H <dbl>, R <dbl>,
#> #   ER <dbl>, HR <dbl>, BB <dbl>, IBB <dbl>, HBP <dbl>, WP <dbl>,
#> #   BK <dbl>, SO <dbl>, GB <dbl>, FB <dbl>, LD <dbl>, IFFB <dbl>,
#> #   Balls <dbl>, Strikes <dbl>, Pitches <dbl>, RS <dbl>, IFH <dbl>,
#> #   BU <dbl>, BUH <dbl>, K_9 <dbl>, BB_9 <dbl>, K_BB <dbl>, H_9 <dbl>,
#> #   HR_9 <dbl>, AVG <dbl>, WHIP <dbl>, BABIP <dbl>, LOB_pct <dbl>, …
# }