Acquire pitch-by-pitch data for Major and Minor League games
Value
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level. Some data will vary depending on the park and the league level, as most sensor data is not available in minor league parks via this API. Note that the column names have mostly been left as-is and there are likely duplicate columns in terms of the information they provide. I plan to clean the output up down the road, but for now I am leaving the majority as-is. Both major and minor league pitch-by-pitch data can be pulled with this function.
col_name | types |
game_pk | numeric |
game_date | character |
index | integer |
startTime | character |
endTime | character |
isPitch | logical |
type | character |
playId | character |
pitchNumber | integer |
details.description | character |
details.event | character |
details.awayScore | integer |
details.homeScore | integer |
details.isScoringPlay | logical |
details.hasReview | logical |
details.code | character |
details.ballColor | character |
details.isInPlay | logical |
details.isStrike | logical |
details.isBall | logical |
details.call.code | character |
details.call.description | character |
count.balls.start | integer |
count.strikes.start | integer |
count.outs.start | integer |
player.id | integer |
player.link | character |
pitchData.strikeZoneTop | numeric |
pitchData.strikeZoneBottom | numeric |
details.fromCatcher | logical |
pitchData.coordinates.x | numeric |
pitchData.coordinates.y | numeric |
hitData.trajectory | character |
hitData.hardness | character |
hitData.location | character |
hitData.coordinates.coordX | numeric |
hitData.coordinates.coordY | numeric |
actionPlayId | character |
details.eventType | character |
details.runnerGoing | logical |
position.code | character |
position.name | character |
position.type | character |
position.abbreviation | character |
battingOrder | character |
atBatIndex | character |
result.type | character |
result.event | character |
result.eventType | character |
result.description | character |
result.rbi | integer |
result.awayScore | integer |
result.homeScore | integer |
about.atBatIndex | integer |
about.halfInning | character |
about.inning | integer |
about.startTime | character |
about.endTime | character |
about.isComplete | logical |
about.isScoringPlay | logical |
about.hasReview | logical |
about.hasOut | logical |
about.captivatingIndex | integer |
count.balls.end | integer |
count.strikes.end | integer |
count.outs.end | integer |
matchup.batter.id | integer |
matchup.batter.fullName | character |
matchup.batter.link | character |
matchup.batSide.code | character |
matchup.batSide.description | character |
matchup.pitcher.id | integer |
matchup.pitcher.fullName | character |
matchup.pitcher.link | character |
matchup.pitchHand.code | character |
matchup.pitchHand.description | character |
matchup.splits.batter | character |
matchup.splits.pitcher | character |
matchup.splits.menOnBase | character |
batted.ball.result | factor |
home_team | character |
home_level_id | integer |
home_level_name | character |
home_parentOrg_id | integer |
home_parentOrg_name | character |
home_league_id | integer |
home_league_name | character |
away_team | character |
away_level_id | integer |
away_level_name | character |
away_parentOrg_id | integer |
away_parentOrg_name | character |
away_league_id | integer |
away_league_name | character |
batting_team | character |
fielding_team | character |
last.pitch.of.ab | character |
pfxId | character |
details.trailColor | character |
details.type.code | character |
details.type.description | character |
pitchData.startSpeed | numeric |
pitchData.endSpeed | numeric |
pitchData.zone | integer |
pitchData.typeConfidence | numeric |
pitchData.plateTime | numeric |
pitchData.extension | numeric |
pitchData.coordinates.aY | numeric |
pitchData.coordinates.aZ | numeric |
pitchData.coordinates.pfxX | numeric |
pitchData.coordinates.pfxZ | numeric |
pitchData.coordinates.pX | numeric |
pitchData.coordinates.pZ | numeric |
pitchData.coordinates.vX0 | numeric |
pitchData.coordinates.vY0 | numeric |
pitchData.coordinates.vZ0 | numeric |
pitchData.coordinates.x0 | numeric |
pitchData.coordinates.y0 | numeric |
pitchData.coordinates.z0 | numeric |
pitchData.coordinates.aX | numeric |
pitchData.breaks.breakAngle | numeric |
pitchData.breaks.breakLength | numeric |
pitchData.breaks.breakY | numeric |
pitchData.breaks.spinRate | integer |
pitchData.breaks.spinDirection | integer |
hitData.launchSpeed | numeric |
hitData.launchAngle | numeric |
hitData.totalDistance | numeric |
injuryType | character |
umpire.id | integer |
umpire.link | character |
isBaseRunningPlay | logical |
isSubstitution | logical |
about.isTopInning | logical |
matchup.postOnFirst.id | integer |
matchup.postOnFirst.fullName | character |
matchup.postOnFirst.link | character |
matchup.postOnSecond.id | integer |
matchup.postOnSecond.fullName | character |
matchup.postOnSecond.link | character |
matchup.postOnThird.id | integer |
matchup.postOnThird.fullName | character |
matchup.postOnThird.link | character |
Examples
# \donttest{
try(mlb_pbp(game_pk = 632970))
#> ── MLB Play-by-Play data from MLB.com ─────────────── baseballr 1.2.0 ──
#> ℹ Data updated: 2022-04-30 07:16:19 UTC
#> # A tibble: 336 × 145
#> game_pk game_date index startTime endTime isPitch type playId
#> <dbl> <chr> <int> <chr> <chr> <lgl> <chr> <chr>
#> 1 632970 2021-08-08 3 2021-08-09T02:… 2021-0… TRUE pitch 932a8…
#> 2 632970 2021-08-08 2 2021-08-09T02:… 2021-0… TRUE pitch e9403…
#> 3 632970 2021-08-08 1 2021-08-09T02:… 2021-0… TRUE pitch 01e5d…
#> 4 632970 2021-08-08 0 2021-08-09T02:… NA FALSE acti… NA
#> 5 632970 2021-08-08 5 2021-08-09T02:… 2021-0… TRUE pitch f0450…
#> 6 632970 2021-08-08 4 2021-08-09T02:… 2021-0… TRUE pitch b4c15…
#> 7 632970 2021-08-08 3 2021-08-09T02:… 2021-0… TRUE pitch e274e…
#> 8 632970 2021-08-08 2 2021-08-09T02:… 2021-0… TRUE pitch d5dc0…
#> 9 632970 2021-08-08 1 2021-08-09T02:… 2021-0… TRUE pitch ddbcc…
#> 10 632970 2021-08-08 0 2021-08-09T02:… 2021-0… TRUE pitch 69a40…
#> # … with 326 more rows, and 137 more variables: pitchNumber <int>,
#> # details.description <chr>, details.event <chr>,
#> # details.awayScore <int>, details.homeScore <int>,
#> # details.isScoringPlay <lgl>, details.hasReview <lgl>,
#> # details.code <chr>, details.ballColor <chr>,
#> # details.isInPlay <lgl>, details.isStrike <lgl>,
#> # details.isBall <lgl>, details.call.code <chr>, …
# }