Skip to contents

This function allows you to scrape schedule and results for a major league team from Baseball-Reference.com

Usage

bref_team_results(Tm, year)

Arguments

Tm

The abbreviation used by Baseball-Reference.com for the team whose results you want to scrape.

year

Season for which you want to scrape the park factors.

Value

Returns a tibble of MLB team results and the following columns:

col_nametypes
Gmnumeric
Datecharacter
Tmcharacter
H_Acharacter
Oppcharacter
Resultcharacter
Rnumeric
RAnumeric
Inncharacter
Recordcharacter
Ranknumeric
GBcharacter
Wincharacter
Losscharacter
Savecharacter
Timecharacter
D/Ncharacter
Attendancenumeric
cLInumeric
Streaknumeric
Orig_Scheduledcharacter
Yearnumeric

Examples

# \donttest{
  try(bref_team_results("NYM", 2015))
#> ── MLB Team Results data from baseball-reference.com ───────────────────
#>  Data updated: 2024-04-13 21:54:27 UTC
#> # A tibble: 162 × 22
#>       Gm Date    Tm    H_A   Opp   Result     R    RA Inn   Record  Rank
#>    <dbl> <chr>   <chr> <chr> <chr> <chr>  <dbl> <dbl> <chr> <chr>  <dbl>
#>  1     1 Monday… NYM   A     WSN   W          3     1 ""    1-0        1
#>  2     2 Wednes… NYM   A     WSN   L          1     2 ""    1-1        2
#>  3     3 Thursd… NYM   A     WSN   W          6     3 ""    2-1        2
#>  4     4 Friday… NYM   A     ATL   L          3     5 ""    2-2        2
#>  5     5 Saturd… NYM   A     ATL   L          3     5 ""    2-3        3
#>  6     6 Sunday… NYM   A     ATL   W          4     3 ""    3-3        2
#>  7     7 Monday… NYM   H     PHI   W          2     0 ""    4-3        2
#>  8     8 Tuesda… NYM   H     PHI   W          6     5 ""    5-3        2
#>  9     9 Wednes… NYM   H     PHI   W          6     1 ""    6-3        1
#> 10    10 Thursd… NYM   H     MIA   W          7     5 ""    7-3        1
#> # ℹ 152 more rows
#> # ℹ 11 more variables: GB <chr>, Win <chr>, Loss <chr>, Save <chr>,
#> #   Time <chr>, `D/N` <chr>, Attendance <dbl>, cLI <dbl>, Streak <dbl>,
#> #   Orig_Scheduled <chr>, Year <dbl>
  try(bref_team_results(Tm="TBR", year=2008))
#> ── MLB Team Results data from baseball-reference.com ───────────────────
#>  Data updated: 2024-04-13 21:54:32 UTC
#> # A tibble: 162 × 22
#>       Gm Date    Tm    H_A   Opp   Result     R    RA Inn   Record  Rank
#>    <dbl> <chr>   <chr> <chr> <chr> <chr>  <dbl> <dbl> <chr> <chr>  <dbl>
#>  1     1 Monday… TBR   A     BAL   W          6     2 ""    1-0        1
#>  2     2 Wednes… TBR   A     BAL   L          6     9 ""    1-1        2
#>  3     3 Friday… TBR   A     NYY   W         13     4 ""    2-1        1
#>  4     4 Saturd… TBR   A     NYY   W          6     3 ""    3-1        1
#>  5     5 Sunday… TBR   A     NYY   L          0     2 ""    3-2        3
#>  6     6 Monday… TBR   A     NYY   L          1     6 ""    3-3        4
#>  7     7 Tuesda… TBR   H     SEA   L          5     6 ""    3-4        5
#>  8     8 Wednes… TBR   H     SEA   L          1     7 ""    3-5        5
#>  9     9 Thursd… TBR   H     SEA   W          7     0 ""    4-5        4
#> 10    10 Friday… TBR   H     BAL   W         10     5 ""    5-5        3
#> # ℹ 152 more rows
#> # ℹ 11 more variables: GB <chr>, Win <chr>, Loss <chr>, Save <chr>,
#> #   Time <chr>, `D/N` <chr>, Attendance <dbl>, cLI <dbl>, Streak <dbl>,
#> #   Orig_Scheduled <chr>, Year <dbl>
# }