Learn R Programming

baseballr (version 1.5.0)

mlb_pbp: Acquire pitch-by-pitch data for Major and Minor League games

Description

Acquire pitch-by-pitch data for Major and Minor League games

Usage

mlb_pbp(game_pk)

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_nametypes
game_pknumeric
game_datecharacter
indexinteger
startTimecharacter
endTimecharacter
isPitchlogical
typecharacter
playIdcharacter
pitchNumberinteger
details.descriptioncharacter
details.eventcharacter
details.awayScoreinteger
details.homeScoreinteger
details.isScoringPlaylogical
details.hasReviewlogical
details.codecharacter
details.ballColorcharacter
details.isInPlaylogical
details.isStrikelogical
details.isBalllogical
details.call.codecharacter
details.call.descriptioncharacter
count.balls.startinteger
count.strikes.startinteger
count.outs.startinteger
player.idinteger
player.linkcharacter
pitchData.strikeZoneTopnumeric
pitchData.strikeZoneBottomnumeric
details.fromCatcherlogical
pitchData.coordinates.xnumeric
pitchData.coordinates.ynumeric
hitData.trajectorycharacter
hitData.hardnesscharacter
hitData.locationcharacter
hitData.coordinates.coordXnumeric
hitData.coordinates.coordYnumeric
actionPlayIdcharacter
details.eventTypecharacter
details.runnerGoinglogical
position.codecharacter
position.namecharacter
position.typecharacter
position.abbreviationcharacter
battingOrdercharacter
atBatIndexcharacter
result.typecharacter
result.eventcharacter
result.eventTypecharacter
result.descriptioncharacter
result.rbiinteger
result.awayScoreinteger
result.homeScoreinteger
about.atBatIndexinteger
about.halfInningcharacter
about.inninginteger
about.startTimecharacter
about.endTimecharacter
about.isCompletelogical
about.isScoringPlaylogical
about.hasReviewlogical
about.hasOutlogical
about.captivatingIndexinteger
count.balls.endinteger
count.strikes.endinteger
count.outs.endinteger
matchup.batter.idinteger
matchup.batter.fullNamecharacter
matchup.batter.linkcharacter
matchup.batSide.codecharacter
matchup.batSide.descriptioncharacter
matchup.pitcher.idinteger
matchup.pitcher.fullNamecharacter
matchup.pitcher.linkcharacter
matchup.pitchHand.codecharacter
matchup.pitchHand.descriptioncharacter
matchup.splits.battercharacter
matchup.splits.pitchercharacter
matchup.splits.menOnBasecharacter
batted.ball.resultfactor
home_teamcharacter
home_level_idinteger
home_level_namecharacter
home_parentOrg_idinteger
home_parentOrg_namecharacter
home_league_idinteger
home_league_namecharacter
away_teamcharacter
away_level_idinteger
away_level_namecharacter
away_parentOrg_idinteger
away_parentOrg_namecharacter
away_league_idinteger
away_league_namecharacter
batting_teamcharacter
fielding_teamcharacter
last.pitch.of.abcharacter
pfxIdcharacter
details.trailColorcharacter
details.type.codecharacter
details.type.descriptioncharacter
pitchData.startSpeednumeric
pitchData.endSpeednumeric
pitchData.zoneinteger
pitchData.typeConfidencenumeric
pitchData.plateTimenumeric
pitchData.extensionnumeric
pitchData.coordinates.aYnumeric
pitchData.coordinates.aZnumeric
pitchData.coordinates.pfxXnumeric
pitchData.coordinates.pfxZnumeric
pitchData.coordinates.pXnumeric
pitchData.coordinates.pZnumeric
pitchData.coordinates.vX0numeric
pitchData.coordinates.vY0numeric
pitchData.coordinates.vZ0numeric
pitchData.coordinates.x0numeric
pitchData.coordinates.y0numeric
pitchData.coordinates.z0numeric
pitchData.coordinates.aXnumeric
pitchData.breaks.breakAnglenumeric
pitchData.breaks.breakLengthnumeric
pitchData.breaks.breakYnumeric
pitchData.breaks.spinRateinteger
pitchData.breaks.spinDirectioninteger
hitData.launchSpeednumeric
hitData.launchAnglenumeric
hitData.totalDistancenumeric
injuryTypecharacter
umpire.idinteger
umpire.linkcharacter
isBaseRunningPlaylogical
isSubstitutionlogical
about.isTopInninglogical
matchup.postOnFirst.idinteger
matchup.postOnFirst.fullNamecharacter
matchup.postOnFirst.linkcharacter
matchup.postOnSecond.idinteger
matchup.postOnSecond.fullNamecharacter
matchup.postOnSecond.linkcharacter
matchup.postOnThird.idinteger
matchup.postOnThird.fullNamecharacter
matchup.postOnThird.linkcharacter

Arguments

game_pk

The date for which you want to find game_pk values for MLB games

Examples

Run this code
# \donttest{
  try(mlb_pbp(game_pk = 632970))
# }

Run the code above in your browser using DataLab