This function allows you to scrape game logs by year for a batter from FanGraphs.com.
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
# \donttest{
try(fg_batter_game_logs(playerid = 19755, year = 2023))
#> ── MLB Batter Game Logs data from FanGraphs.com ───── baseballr 1.6.0 ──
#> ℹ Data updated: 2024-04-13 21:55:00 UTC
#> # A tibble: 135 × 250
#> PlayerName playerid Date Team Opp season Age BatOrder Pos
#> <chr> <int> <chr> <chr> <chr> <int> <int> <chr> <chr>
#> 1 Shohei Ohtani 19755 2023-… LAA @OAK 2023 28 2 DH
#> 2 Shohei Ohtani 19755 2023-… LAA @OAK 2023 28 2 DH
#> 3 Shohei Ohtani 19755 2023-… LAA @OAK 2023 28 3 DH
#> 4 Shohei Ohtani 19755 2023-… LAA @PHI 2023 28 3 DH
#> 5 Shohei Ohtani 19755 2023-… LAA @PHI 2023 28 2 DH
#> 6 Shohei Ohtani 19755 2023-… LAA @PHI 2023 28 2 DH
#> 7 Shohei Ohtani 19755 2023-… LAA @NYM 2023 28 2 DH
#> 8 Shohei Ohtani 19755 2023-… LAA @NYM 2023 28 2 DH
#> 9 Shohei Ohtani 19755 2023-… LAA @NYM 2023 28 2 DH
#> 10 Shohei Ohtani 19755 2023-… LAA CIN 2023 28 2 DH
#> # ℹ 125 more rows
#> # ℹ 241 more variables: G <dbl>, AB <dbl>, PA <dbl>, H <dbl>,
#> # `1B` <dbl>, `2B` <dbl>, `3B` <dbl>, HR <dbl>, R <dbl>, RBI <dbl>,
#> # BB <dbl>, IBB <dbl>, SO <dbl>, HBP <dbl>, SF <dbl>, SH <dbl>,
#> # GDP <dbl>, SB <dbl>, CS <dbl>, AVG <dbl>, GB <dbl>, FB <dbl>,
#> # LD <dbl>, IFFB <dbl>, Pitches <dbl>, Balls <dbl>, Strikes <dbl>,
#> # IFH <dbl>, BU <dbl>, BUH <dbl>, `BB%` <dbl>, `K%` <dbl>, …
# }