Skip to contents

This function allows you to scrape basic batter statistics over a custom time frame. Data is sourced from Baseball-Reference.com.

Usage

bref_daily_batter(t1, t2)

Arguments

t1

First date data should be scraped from. Should take the form "YEAR-MONTH-DAY"

t2

Last date data should be scraped from. Should take the form "YEAR-MONTH-DAY"

Value

Returns a tibble of batter performance over the requested date range, one row per player, with the following columns:

col_nametypesdescription
bbref_idcharacterBaseball-Reference player id (slug).
seasonintegerSeason year.
NamecharacterPlayer name.
AgenumericPlayer age during the season.
LevelcharacterLeague level (e.g. Maj-AL, Maj-NL).
TeamcharacterTeam name.
GnumericGames played.
PAnumericPlate appearances.
ABnumericAt-bats.
RnumericRuns scored.
HnumericHits.
X1BnumericSingles.
X2BnumericDoubles.
X3BnumericTriples.
HRnumericHome runs.
RBInumericRuns batted in.
BBnumericWalks (bases on balls).
IBBnumericIntentional walks.
uBBnumericUnintentional walks.
SOnumericStrikeouts.
HBPnumericTimes hit by pitch.
SHnumericSacrifice hits (bunts).
SFnumericSacrifice flies.
GDPnumericGrounded into double plays.
SBnumericStolen bases.
CSnumericTimes caught stealing.
BAnumericBatting average.
OBPnumericOn-base percentage.
SLGnumericSlugging percentage.
OPSnumericOn-base plus slugging.

Examples

# \donttest{
  try(bref_daily_batter(t1="2015-05-10", t2="2015-06-20"))
#> ── MLB Daily Batter data from baseball-reference.com ───────────────────
#>  Data updated: 2026-06-08 11:06:34 UTC
#> # A tibble: 658 × 30
#>    bbref_id season Name    Age Level Team      G    PA    AB     R     H
#>    <chr>     <int> <chr> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1 machama…   2015 Mann…    22 Maj-… Balt…    40   175   163    30    51
#>  2 blackch…   2015 Char…    28 Maj-… Colo…    40   175   153    24    37
#>  3 kipnija…   2015 Jaso…    28 Maj-… Clev…    37   174   143    31    57
#>  4 donaljo…   2015 Josh…    29 Maj-… Toro…    39   174   155    30    45
#>  5 burnsbi…   2015 Bill…    25 Maj-… Oakl…    37   172   159    25    52
#>  6 markani…   2015 Nick…    31 Maj-… Atla…    39   172   148    14    44
#>  7 choosh01   2015 Shin…    32 Maj-… Texas    38   172   155    24    42
#>  8 gordode…   2015 Dee …    27 Maj-… Miami    38   172   168    19    49
#>  9 fowlede…   2015 Dext…    29 Maj-… Chic…    37   170   148    28    32
#> 10 goldspa…   2015 Paul…    27 Maj-… Ariz…    39   169   133    26    48
#> # ℹ 648 more rows
#> # ℹ 19 more variables: X1B <dbl>, X2B <dbl>, X3B <dbl>, HR <dbl>,
#> #   RBI <dbl>, BB <dbl>, IBB <dbl>, uBB <dbl>, SO <dbl>, HBP <dbl>,
#> #   SH <dbl>, SF <dbl>, GDP <dbl>, SB <dbl>, CS <dbl>, BA <dbl>,
#> #   OBP <dbl>, SLG <dbl>, OPS <dbl>
# }