Skip to contents

MLB Team Individual Stats

Usage

mlb_team_stats(
  team_id = NULL,
  stat_type = NULL,
  game_type = NULL,
  stat_group = NULL,
  season = NULL,
  sport_ids = NULL
)

Arguments

team_id

Team ID to return information and ranking for a particular statistic for a particular team.

stat_type

Stat type to return statistics for.

game_type

Game type to return information for a particular statistic in a particular game type.

stat_group

Stat group to return information and ranking for a particular statistic in a particular group.

season

Year to return information and ranking for a particular statistic in a given year.

sport_ids

The sport_id(s) to return information and ranking information for.

Value

Returns a tibble with the following columns

col_nametypesdescription
seasoncharacterSeason year for the statistic.
games_playedintegerGames played.
ground_outsintegerGround outs.
air_outsintegerAir outs (fly outs).
runsintegerRuns scored.
doublesintegerDoubles.
triplesintegerTriples.
home_runsintegerHome runs.
strike_outsintegerStrikeouts.
base_on_ballsintegerWalks (bases on balls).
intentional_walksintegerIntentional walks.
hitsintegerHits.
hit_by_pitchintegerTimes hit by pitch.
avgcharacterBatting average.
at_batsintegerAt bats.
obpcharacterOn-base percentage.
slgcharacterSlugging percentage.
opscharacterOn-base plus slugging.
caught_stealingintegerTimes caught stealing.
stolen_basesintegerStolen bases.
stolen_base_percentagecharacterStolen base success percentage.
caught_stealing_percentagecharacterCaught stealing percentage.
ground_into_double_playintegerGrounded into double plays.
number_of_pitchesintegerTotal pitches seen.
plate_appearancesintegerPlate appearances.
total_basesintegerTotal bases.
rbiintegerRuns batted in.
left_on_baseintegerRunners left on base.
sac_buntsintegerSacrifice bunts.
sac_fliesintegerSacrifice flies.
babipcharacterBatting average on balls in play.
ground_outs_to_airoutscharacterRatio of ground outs to air outs.
catchers_interferenceintegerTimes reached on catcher's interference.
at_bats_per_home_runcharacterAt bats per home run.
team_idintegerTeam MLBAM ID.
team_namecharacterTeam name.
team_linkcharacterAPI link to the team.
type_display_namecharacterStat type display name.
group_display_namecharacterStat group display name.

Examples

# \donttest{
  try(mlb_team_stats(team_id = 137, stat_type = 'season', stat_group = 'hitting', season = 2021))
#> ── MLB Team Stats data from MLB.com ───────────────── baseballr 2.0.0 ──
#>  Data updated: 2026-06-12 14:09:58 UTC
#> # A tibble: 1 × 39
#>   season games_played ground_outs air_outs  runs doubles triples
#>   <chr>         <int>       <int>    <int> <int>   <int>   <int>
#> 1 2021            162        1304     1403   804     271      25
#> # ℹ 32 more variables: home_runs <int>, strike_outs <int>,
#> #   base_on_balls <int>, intentional_walks <int>, hits <int>,
#> #   hit_by_pitch <int>, avg <chr>, at_bats <int>, obp <chr>, slg <chr>,
#> #   ops <chr>, caught_stealing <int>, stolen_bases <int>,
#> #   stolen_base_percentage <chr>, caught_stealing_percentage <chr>,
#> #   ground_into_double_play <int>, number_of_pitches <int>,
#> #   plate_appearances <int>, total_bases <int>, rbi <int>, …
# }