Acquire pitch-by-pitch data between two timecodes for Major and Minor League games
Source:R/mlb_pbp_diff.R
mlb_pbp_diff.Rd
Acquire pitch-by-pitch data between two timecodes for Major and Minor League games
Arguments
- game_pk
The date for which you want to find game_pk values for MLB games
- start_timecode
The start time code for the MLB game (format: MMDDYYYY_HHMMSS)
- end_timecode
The end time code for the MLB game (format: MMDDYYYY_HHMMSS)
Value
Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level between the start_timecode and end_timecode
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 |
about.isTopInning | logical |
matchup.postOnFirst.id | integer |
matchup.postOnFirst.fullName | character |
matchup.postOnFirst.link | character |
Examples
# \donttest{
try(mlb_pbp_diff(game_pk = 632970,
start_timecode = "20210808_231704",
end_timecode = "20210808_233711"))
#> ── MLB Play-by-Play diff data from MLB.com ────────── baseballr 1.6.0 ──
#> ℹ Data updated: 2024-04-13 21:56:35 UTC
#> # A tibble: 50 × 141
#> game_pk game_date index startTime endTime isPitch type playId
#> <dbl> <chr> <int> <chr> <chr> <lgl> <chr> <chr>
#> 1 632970 2021-08-08 2 2021-08-08T23:… 2021-0… TRUE pitch 0c67e…
#> 2 632970 2021-08-08 1 2021-08-08T23:… 2021-0… TRUE pitch 51631…
#> 3 632970 2021-08-08 0 2021-08-08T23:… 2021-0… TRUE pitch e3edf…
#> 4 632970 2021-08-08 2 2021-08-08T23:… 2021-0… TRUE pitch 65870…
#> 5 632970 2021-08-08 1 2021-08-08T23:… 2021-0… TRUE pitch d5fc8…
#> 6 632970 2021-08-08 0 2021-08-08T23:… 2021-0… TRUE pitch 0a6c9…
#> 7 632970 2021-08-08 4 2021-08-08T23:… 2021-0… TRUE pitch 506d0…
#> 8 632970 2021-08-08 3 2021-08-08T23:… 2021-0… TRUE pitch 24f33…
#> 9 632970 2021-08-08 2 2021-08-08T23:… 2021-0… TRUE pitch aae6b…
#> 10 632970 2021-08-08 1 2021-08-08T23:… 2021-0… TRUE pitch 63658…
#> # ℹ 40 more rows
#> # ℹ 133 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>, …
# }