Skip to contents

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

A data frame of pitcher game logs, one row per game, with the following columns:

col_nametypesdescription
PlayerNamecharacterPlayer name.
playeridintegerFanGraphs player ID.
DatecharacterCalendar date of the game (YYYY-MM-DD).
OppcharacterOpponent team; leading @ indicates a road game.
teamidintegerFanGraphs team ID.
seasonintegerSeason year.
TeamcharacterTeam the player appeared for.
HomeAwaycharacterHome/away indicator for the game.
AgeintegerPlayer age during the season.
WnumericWins.
LnumericLosses.
ERAnumericEarned run average.
GnumericGames (1 per row).
GSnumericGames started.
QSnumericQuality starts.
CGnumericComplete games.
ShOnumericShutouts.
SVnumericSaves.
HLDnumericHolds.
BSnumericBlown saves.
IPnumericInnings pitched.
TBFnumericTotal batters faced.
HnumericHits.
RnumericRuns scored.
ERnumericEarned runs allowed.
HRnumericHome runs.
BBnumericWalks (bases on balls).
IBBnumericIntentional walks.
HBPnumericTimes hit by pitch.
WPnumericWild pitches.
BKnumericBalks.
SOnumericStrikeouts.
K/9numericStrikeouts per 9 innings.
BB/9numericWalks per 9 innings.
H/9numericHits per 9 innings.
K/BBnumericStrikeout-to-walk ratio.
IFH%numericInfield-hit rate.
BUH%numericBunt-hit rate.
GBnumericGround balls.
FBnumericFly balls.
LDnumericLine drives.
IFFBnumericInfield fly balls.
IFHnumericInfield hits.
BUnumericBunts.
BUHnumericBunt hits.
K%numericStrikeout rate.
BB%numericWalk rate.
K-BB%numericStrikeout rate minus walk rate.
SIERAnumericSkill-interactive ERA.
HR/9numericHome runs per 9 innings.
AVGnumericBatting average.
WHIPnumericWalks plus hits per inning pitched.
BABIPnumericBatting average on balls in play.
LOB%numericLeft-on-base percentage (strand rate).
FIPnumericFielding independent pitching.
E-FnumericERA minus FIP.
xFIPnumericExpected fielding independent pitching.
ERA-numericERA scaled to league/park (100 = average).
FIP-numericFIP scaled to league/park (100 = average).
xFIP-numericxFIP scaled to league/park (100 = average).
GB/FBnumericGround-ball to fly-ball ratio.
LD%numericLine-drive rate.
GB%numericGround-ball rate.
FB%numericFly-ball rate.
IFFB%numericInfield-fly-ball rate.
HR/FBnumericHome-run-per-fly-ball rate.
RSnumericRun support.
RS/9numericRun support per 9 innings.
BallsnumericBalls.
StrikesnumericStrikes.
PitchesnumericPitches seen.
WPAnumericWin probability added.
-WPAnumericNegative win probability added.
+WPAnumericPositive win probability added.
RE24numericRun expectancy based on 24 base-out states.
REWnumericRun expectancy wins.
pLInumericAverage leverage index.
inLInumericAverage leverage index entering games.
gmLInumericAverage leverage index at game entry.
exLInumericAverage leverage index exiting games.
PullsnumericTimes pulled from games.
GamesnumericGames appeared in.
WPA/LInumericContext-neutral win probability added.
ClutchnumericClutch performance score.
SDnumericShutdowns.
MDnumericMeltdowns.
FB%1numericFastball usage rate.
FBvnumericAverage four-seam fastball velocity (mph).
SL%numericslider usage rate.
SLvnumericAverage slider velocity (mph).
CT%numericcutter usage rate.
CTvnumericAverage cutter velocity (mph).
CB%numericcurveball usage rate.
CBvnumericAverage curveball velocity (mph).
SF%numericsplit-finger fastball usage rate.
SFvnumericAverage split-finger fastball velocity (mph).
XX%numericunknown/other pitch usage rate.
wFBnumericTotal runs above average on the fastball.
wSLnumericTotal runs above average on the slider.
wCTnumericTotal runs above average on the cutter.
wCBnumericTotal runs above average on the curveball.
wSFnumericTotal runs above average on the split-finger fastball.
wFB/CnumericRuns above average per 100 fastballs.
wSL/CnumericRuns above average per 100 sliders.
wCT/CnumericRuns above average per 100 cutters.
wCB/CnumericRuns above average per 100 curveballs.
wSF/CnumericRuns above average per 100 split-finger fastballs.
O-Swing%numericSwing rate on pitches outside the zone.
Z-Swing%numericSwing rate on pitches in the zone.
Swing%numericOverall swing rate.
O-Contact%numericContact rate on pitches outside the zone.
Z-Contact%numericContact rate on pitches in the zone.
Contact%numericOverall contact rate.
Zone%numericRate of pitches in the strike zone.
F-Strike%numericFirst-pitch strike rate.
SwStr%numericSwinging-strike rate.
PullnumericPulled batted balls.
CentnumericBatted balls hit up the middle.
OpponumericOpposite-field batted balls.
SoftnumericSoft-hit batted balls.
MednumericMedium-hit batted balls.
HardnumericHard-hit batted balls.
bipCountnumericBalls in play.
Pull%numericPulled batted-ball rate.
Cent%numericUp-the-middle batted-ball rate.
Oppo%numericOpposite-field batted-ball rate.
Soft%numericSoft-contact rate.
Med%numericMedium-contact rate.
Hard%numericHard-contact rate.
tERAnumericTrue ERA (batted-ball based).
GSv2numericGame Score (version 2).
pb_o_CUnumericPitchingBot overall grade for the curveball.
pb_s_CUnumericPitchingBot stuff grade for the curveball.
pb_c_CUnumericPitchingBot command grade for the curveball.
pb_o_FFnumericPitchingBot overall grade for the four-seam fastball.
pb_s_FFnumericPitchingBot stuff grade for the four-seam fastball.
pb_c_FFnumericPitchingBot command grade for the four-seam fastball.
pb_o_SInumericPitchingBot overall grade for the sinker.
pb_s_SInumericPitchingBot stuff grade for the sinker.
pb_c_SInumericPitchingBot command grade for the sinker.
pb_o_SLnumericPitchingBot overall grade for the slider.
pb_s_SLnumericPitchingBot stuff grade for the slider.
pb_c_SLnumericPitchingBot command grade for the slider.
pb_o_FCnumericPitchingBot overall grade for the cutter.
pb_s_FCnumericPitchingBot stuff grade for the cutter.
pb_c_FCnumericPitchingBot command grade for the cutter.
pb_o_FSnumericPitchingBot overall grade for the splitter.
pb_s_FSnumericPitchingBot stuff grade for the splitter.
pb_c_FSnumericPitchingBot command grade for the splitter.
pb_overallnumericPitchingBot overall grade.
pb_stuffnumericPitchingBot stuff grade.
pb_commandnumericPitchingBot command grade.
pb_xRV100numericPitchingBot expected run value per 100 pitches.
pb_ERAnumericPitchingBot ERA estimate.
sp_s_CUnumericStuff+ grade for the curveball (100 = average).
sp_l_CUnumericLocation+ grade for the curveball (100 = average).
sp_p_CUnumericPitching+ grade for the curveball (100 = average).
sp_s_FFnumericStuff+ grade for the four-seam fastball (100 = average).
sp_l_FFnumericLocation+ grade for the four-seam fastball (100 = average).
sp_p_FFnumericPitching+ grade for the four-seam fastball (100 = average).
sp_s_SInumericStuff+ grade for the sinker (100 = average).
sp_l_SInumericLocation+ grade for the sinker (100 = average).
sp_p_SInumericPitching+ grade for the sinker (100 = average).
sp_s_SLnumericStuff+ grade for the slider (100 = average).
sp_l_SLnumericLocation+ grade for the slider (100 = average).
sp_p_SLnumericPitching+ grade for the slider (100 = average).
sp_s_FCnumericStuff+ grade for the cutter (100 = average).
sp_l_FCnumericLocation+ grade for the cutter (100 = average).
sp_p_FCnumericPitching+ grade for the cutter (100 = average).
sp_s_FSnumericStuff+ grade for the splitter (100 = average).
sp_l_FSnumericLocation+ grade for the splitter (100 = average).
sp_p_FSnumericPitching+ grade for the splitter (100 = average).
sp_stuffnumericOverall Stuff+ grade (100 = average).
sp_locationnumericOverall Location+ grade (100 = average).
sp_pitchingnumericOverall Pitching+ grade (100 = average).
PPTVnumericPitch-type and framing run value component.
CPTVnumericPitch-type and framing run value component.
BPTVnumericPitch-type and framing run value component.
DSVnumericPitch-type and framing run value component.
DGVnumericPitch-type and framing run value component.
BTVnumericPitch-type and framing run value component.
rPPTVnumericPitch-type and framing run value component.
rBPTVnumericPitch-type and framing run value component.
EBVnumericPitch-type and framing run value component.
ESVnumericPitch-type and framing run value component.
rFTeamVnumericPitch-type and framing run value component.
rBTeamVnumericPitch-type and framing run value component.
rTVnumericPitch-type and framing run value component.
xERAnumericExpected ERA.
pfxFA%numericPITCHf/x four-seam fastball usage rate.
pfxFC%numericPITCHf/x cutter usage rate.
pfxFS%numericPITCHf/x splitter usage rate.
pfxSI%numericPITCHf/x sinker usage rate.
pfxSL%numericPITCHf/x slider usage rate.
pfxCU%numericPITCHf/x curveball usage rate.
pfxSLO%numericPITCHf/x slurve usage rate.
pfxST%numericPITCHf/x sweeper usage rate.
pfxCUO%numericPITCHf/x other curve usage rate.
pfxvFAnumericPITCHf/x average four-seam fastball velocity (mph).
pfxvFCnumericPITCHf/x average cutter velocity (mph).
pfxvFSnumericPITCHf/x average splitter velocity (mph).
pfxvSInumericPITCHf/x average sinker velocity (mph).
pfxvSLnumericPITCHf/x average slider velocity (mph).
pfxvCUnumericPITCHf/x average curveball velocity (mph).
pfxvSLOnumericPITCHf/x average slurve velocity (mph).
pfxvSTnumericPITCHf/x average sweeper velocity (mph).
pfxvCUOnumericPITCHf/x average other curve velocity (mph).
pfxFA-XnumericPITCHf/x horizontal movement of the four-seam fastball (inches).
pfxFC-XnumericPITCHf/x horizontal movement of the cutter (inches).
pfxFS-XnumericPITCHf/x horizontal movement of the splitter (inches).
pfxSI-XnumericPITCHf/x horizontal movement of the sinker (inches).
pfxSL-XnumericPITCHf/x horizontal movement of the slider (inches).
pfxCU-XnumericPITCHf/x horizontal movement of the curveball (inches).
pfxSLO-XnumericPITCHf/x horizontal movement of the slurve (inches).
pfxST-XnumericPITCHf/x horizontal movement of the sweeper (inches).
pfxCUO-XnumericPITCHf/x horizontal movement of the other curve (inches).
pfxFA-ZnumericPITCHf/x vertical movement of the four-seam fastball (inches).
pfxFC-ZnumericPITCHf/x vertical movement of the cutter (inches).
pfxFS-ZnumericPITCHf/x vertical movement of the splitter (inches).
pfxSI-ZnumericPITCHf/x vertical movement of the sinker (inches).
pfxSL-ZnumericPITCHf/x vertical movement of the slider (inches).
pfxCU-ZnumericPITCHf/x vertical movement of the curveball (inches).
pfxSLO-ZnumericPITCHf/x vertical movement of the slurve (inches).
pfxST-ZnumericPITCHf/x vertical movement of the sweeper (inches).
pfxCUO-ZnumericPITCHf/x vertical movement of the other curve (inches).
pfxwFAnumericPITCHf/x total runs above average on the four-seam fastball.
pfxwFCnumericPITCHf/x total runs above average on the cutter.
pfxwFSnumericPITCHf/x total runs above average on the splitter.
pfxwSInumericPITCHf/x total runs above average on the sinker.
pfxwSLnumericPITCHf/x total runs above average on the slider.
pfxwCUnumericPITCHf/x total runs above average on the curveball.
pfxwSLOnumericPITCHf/x total runs above average on the slurve.
pfxwSTnumericPITCHf/x total runs above average on the sweeper.
pfxwCUOnumericPITCHf/x total runs above average on the other curve.
pfxwFA/CnumericPITCHf/x runs above average per 100 four-seam fastballs.
pfxwFC/CnumericPITCHf/x runs above average per 100 cutters.
pfxwFS/CnumericPITCHf/x runs above average per 100 splitters.
pfxwSI/CnumericPITCHf/x runs above average per 100 sinkers.
pfxwSL/CnumericPITCHf/x runs above average per 100 sliders.
pfxwCU/CnumericPITCHf/x runs above average per 100 curveballs.
pfxwSLO/CnumericPITCHf/x runs above average per 100 slurves.
pfxwST/CnumericPITCHf/x runs above average per 100 sweepers.
pfxwCUO/CnumericPITCHf/x runs above average per 100 other curves.
pfxaaFAnumericPITCHf/x average spin/active component on the four-seam fastball.
pfxaaFCnumericPITCHf/x average spin/active component on the cutter.
pfxaaFSnumericPITCHf/x average spin/active component on the splitter.
pfxaaSInumericPITCHf/x average spin/active component on the sinker.
pfxaaSLnumericPITCHf/x average spin/active component on the slider.
pfxaaCUnumericPITCHf/x average spin/active component on the curveball.
pfxaaSLOnumericPITCHf/x average spin/active component on the slurve.
pfxaaSTnumericPITCHf/x average spin/active component on the sweeper.
pfxaaCUOnumericPITCHf/x average spin/active component on the other curve.
pfxspFAnumericPITCHf/x average spin rate on the four-seam fastball (rpm).
pfxspFCnumericPITCHf/x average spin rate on the cutter (rpm).
pfxspFSnumericPITCHf/x average spin rate on the splitter (rpm).
pfxspSInumericPITCHf/x average spin rate on the sinker (rpm).
pfxspSLnumericPITCHf/x average spin rate on the slider (rpm).
pfxspCUnumericPITCHf/x average spin rate on the curveball (rpm).
pfxspSLOnumericPITCHf/x average spin rate on the slurve (rpm).
pfxspSTnumericPITCHf/x average spin rate on the sweeper (rpm).
pfxspCUOnumericPITCHf/x average spin rate on the other curve (rpm).
pfxO-Swing%numericPITCHf/x Swing rate on pitches outside the zone.
pfxZ-Swing%numericPITCHf/x Swing rate on pitches in the zone.
pfxSwing%numericPITCHf/x Overall swing rate.
pfxO-Contact%numericPITCHf/x Contact rate on pitches outside the zone.
pfxZ-Contact%numericPITCHf/x Contact rate on pitches in the zone.
pfxContact%numericPITCHf/x Overall contact rate.
pfxZone%numericPITCHf/x Rate of pitches in the strike zone.
pfxPacenumericPITCHf/x Average seconds between pitches.
AvgBatSpeednumericAverage bat speed (mph).
FastSwing%numericRate of fast swings.
SwingLengthnumericAverage swing length (feet).
SquaredUpContact%numericSquared-up rate per contact.
SquaredUpSwing%numericSquared-up rate per swing.
BlastContact%numericBlast rate per contact.
BlastSwing%numericBlast rate per swing.
SwordsnumericSwords (especially ugly swinging strikeouts).
CompetitiveSwingsnumericCompetitive swings.
TiltnumericAverage swing tilt (degrees).
AttackAnglenumericAverage attack angle (degrees).
AttackDirectionnumericAverage attack direction (degrees).
IdealAttackAngle%numericRate of swings in the ideal attack-angle range.
DepthInBoxnumericAverage depth in the batter's box (inches).
DistanceOffPlatenumericAverage distance off the plate (inches).
scH-Swing%numericStatcast heart-zone swing rate.
scH-Contact%numericStatcast heart-zone contact rate.
scH-Zone%numericStatcast heart-zone zone rate.
scS-Swing%numericStatcast shadow-zone swing rate.
scS-Contact%numericStatcast shadow-zone contact rate.
scS-Zone%numericStatcast shadow-zone zone rate.
scC-Swing%numericStatcast chase-zone swing rate.
scC-Contact%numericStatcast chase-zone contact rate.
scC-Zone%numericStatcast chase-zone zone rate.
scW-Swing%numericStatcast waste-zone swing rate.
scW-Contact%numericStatcast waste-zone contact rate.
scW-Zone%numericStatcast waste-zone zone rate.
scSI-Swing%numericStatcast in-zone strike-zone swing rate.
scSI-Contact%numericStatcast in-zone strike-zone contact rate.
scSI-Zone%numericStatcast in-zone strike-zone zone rate.
scSO-Swing%numericStatcast out-of-zone strike-zone swing rate.
scSO-Contact%numericStatcast out-of-zone strike-zone contact rate.
scSO-Zone%numericStatcast out-of-zone strike-zone zone rate.
scO-Swing%numericStatcast out-of-zone-zone swing rate.
scO-Contact%numericStatcast out-of-zone-zone contact rate.
scO-Zone%numericStatcast out-of-zone-zone zone rate.
scZ-Swing%numericStatcast in-zone-zone swing rate.
scZ-Contact%numericStatcast in-zone-zone contact rate.
scZ-Zone%numericStatcast in-zone-zone zone rate.
piCU%numericPITCHInfo curveball usage rate.
piFA%numericPITCHInfo four-seam fastball usage rate.
piFC%numericPITCHInfo cutter usage rate.
piFS%numericPITCHInfo splitter usage rate.
piSI%numericPITCHInfo sinker usage rate.
piSL%numericPITCHInfo slider usage rate.
piXX%numericPITCHInfo unknown/other pitch usage rate.
pivCUnumericPITCHInfo average curveball velocity (mph).
pivFAnumericPITCHInfo average four-seam fastball velocity (mph).
pivFCnumericPITCHInfo average cutter velocity (mph).
pivFSnumericPITCHInfo average splitter velocity (mph).
pivSInumericPITCHInfo average sinker velocity (mph).
pivSLnumericPITCHInfo average slider velocity (mph).
pivXXnumericPITCHInfo average unknown/other pitch velocity (mph).
piCU-XnumericPITCHInfo horizontal movement of the curveball (inches).
piFA-XnumericPITCHInfo horizontal movement of the four-seam fastball (inches).
piFC-XnumericPITCHInfo horizontal movement of the cutter (inches).
piFS-XnumericPITCHInfo horizontal movement of the splitter (inches).
piSI-XnumericPITCHInfo horizontal movement of the sinker (inches).
piSL-XnumericPITCHInfo horizontal movement of the slider (inches).
piXX-XnumericPITCHInfo horizontal movement of the unknown/other pitch (inches).
piCU-ZnumericPITCHInfo vertical movement of the curveball (inches).
piFA-ZnumericPITCHInfo vertical movement of the four-seam fastball (inches).
piFC-ZnumericPITCHInfo vertical movement of the cutter (inches).
piFS-ZnumericPITCHInfo vertical movement of the splitter (inches).
piSI-ZnumericPITCHInfo vertical movement of the sinker (inches).
piSL-ZnumericPITCHInfo vertical movement of the slider (inches).
piXX-ZnumericPITCHInfo vertical movement of the unknown/other pitch (inches).
piwCUnumericPITCHInfo total runs above average on the curveball.
piwFAnumericPITCHInfo total runs above average on the four-seam fastball.
piwFCnumericPITCHInfo total runs above average on the cutter.
piwFSnumericPITCHInfo total runs above average on the splitter.
piwSInumericPITCHInfo total runs above average on the sinker.
piwSLnumericPITCHInfo total runs above average on the slider.
piwXXnumericPITCHInfo total runs above average on the unknown/other pitch.
piwCU/CnumericPITCHInfo runs above average per 100 curveballs.
piwFA/CnumericPITCHInfo runs above average per 100 four-seam fastballs.
piwFC/CnumericPITCHInfo runs above average per 100 cutters.
piwFS/CnumericPITCHInfo runs above average per 100 splitters.
piwSI/CnumericPITCHInfo runs above average per 100 sinkers.
piwSL/CnumericPITCHInfo runs above average per 100 sliders.
piwXX/CnumericPITCHInfo runs above average per 100 unknown/other pitchs.
piO-Swing%numericPITCHInfo Swing rate on pitches outside the zone.
piZ-Swing%numericPITCHInfo Swing rate on pitches in the zone.
piSwing%numericPITCHInfo Overall swing rate.
piO-Contact%numericPITCHInfo Contact rate on pitches outside the zone.
piZ-Contact%numericPITCHInfo Contact rate on pitches in the zone.
piContact%numericPITCHInfo Overall contact rate.
piZone%numericPITCHInfo Rate of pitches in the strike zone.
EventsnumericBatted-ball events with Statcast data.
EVnumericAverage exit velocity (mph).
LAnumericAverage launch angle (degrees).
BarrelsnumericBarreled batted balls.
Barrel%numericBarrel rate (per batted-ball event).
maxEVnumericMaximum exit velocity (mph).
HardHitnumericHard-hit batted balls (95+ mph).
HardHit%numericHard-hit rate (95+ mph).
gamedatecharacterGame date as parsed from the source feed.
dhintegerDoubleheader game indicator (0 = single game).

Examples

# \donttest{
  try(fg_pitcher_game_logs(playerid = "19755", year = 2023))
#> ── MLB Pitcher Game Log data from FanGraphs.com ───── baseballr 2.0.0 ──
#>  Data updated: 2026-06-09 20:42:53 UTC
#> # A tibble: 23 × 367
#>    PlayerName    playerid Date  Opp   teamid season Team  HomeAway   Age
#>    <chr>            <int> <chr> <chr>  <int>  <int> <chr> <chr>    <int>
#>  1 Shohei Ohtani    19755 2023… CIN        1   2023 LAA   H           28
#>  2 Shohei Ohtani    19755 2023… SFG        1   2023 LAA   H           28
#>  3 Shohei Ohtani    19755 2023… SEA        1   2023 LAA   H           28
#>  4 Shohei Ohtani    19755 2023… @DET       1   2023 LAA   A           28
#>  5 Shohei Ohtani    19755 2023… PIT        1   2023 LAA   H           28
#>  6 Shohei Ohtani    19755 2023… HOU        1   2023 LAA   H           28
#>  7 Shohei Ohtani    19755 2023… @SDP       1   2023 LAA   A           28
#>  8 Shohei Ohtani    19755 2023… CHW        1   2023 LAA   H           28
#>  9 Shohei Ohtani    19755 2023… LAD        1   2023 LAA   H           28
#> 10 Shohei Ohtani    19755 2023… @TEX       1   2023 LAA   A           28
#> # ℹ 13 more rows
#> # ℹ 358 more variables: W <dbl>, L <dbl>, ERA <dbl>, G <dbl>, GS <dbl>,
#> #   QS <dbl>, CG <dbl>, ShO <dbl>, SV <dbl>, HLD <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>,
#> #   `K/9` <dbl>, `BB/9` <dbl>, `H/9` <dbl>, `K/BB` <dbl>, `IFH%` <dbl>,
#> #   `BUH%` <dbl>, GB <dbl>, FB <dbl>, LD <dbl>, IFFB <dbl>, …
# }