Title: | Scrapes Or Collects NFL Data From ESPN |
---|---|
Description: | Main use case is to collect ESPN QBR for NFL and college football. Alternative functions include getting NFL standings and scraping NFL season-level stats. |
Authors: | Thomas Mock |
Maintainer: | Thomas Mock <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.8.0 |
Built: | 2024-11-14 03:59:32 UTC |
Source: | https://github.com/jthomasmock/espnscrapeR |
Get ELO ratings from FiveThirtyEight
get_538_elo(season = 2020, stat = "weekly_elo")
get_538_elo(season = 2020, stat = "weekly_elo")
season |
character or numeric, must be 2015 or greater |
stat |
character, must be one of "games", "weekly_elo", "weekly_rating", "distance", "qb_adj_playoff", "qb_adj" |
Returns a tibble
# Get elo for specific season and stat get_538_elo(season = 2020, stat = "weekly_elo")
# Get elo for specific season and stat get_538_elo(season = 2020, stat = "weekly_elo")
Get historical ELO ratings from FiveThirtyEight
get_538_elo_historical(team = "pit")
get_538_elo_historical(team = "pit")
team |
character, team abbreviated name, must be one of "ari", "atl", "bal", "buf", "car", "chi", "cin", "cle", "dal", "den", "det", "gb", "hou", "ind", "jax", "kc", "oak", "lac", "lar", "mia", "min", "ne", "no", "nyg", "nyj", "phi", "pit", "sf", "sea", "tb", "ten", "wsh" |
Returns a tibble
# Get historic elo for specific team get_538_elo_historical(team = "pit")
# Get historic elo for specific team get_538_elo_historical(team = "pit")
Get ESPN athlete info for NFL players
get_athlete(athlete_id)
get_athlete(athlete_id)
athlete_id |
The player's unique athlete id |
Returns a tibble
# Get ALL Playoff QBR from 2016 season get_athlete("2580")
# Get ALL Playoff QBR from 2016 season get_athlete("2580")
Get ESPN QBR for College football
get_college_qbr(season = 2020, type = "season")
get_college_qbr(season = 2020, type = "season")
season |
Numeric or character - greater than 2004 |
type |
character - "season" or "weekly" |
tibble
# Get college QBR from 2014 for players at season level get_college_qbr(season = 2014, type = "season") # Get weekly college QBR from 2019 # Note the mix of playoffs/bowls and regular season get_college_qbr(2019, type = "weekly")
# Get college QBR from 2014 for players at season level get_college_qbr(season = 2014, type = "season") # Get weekly college QBR from 2019 # Note the mix of playoffs/bowls and regular season get_college_qbr(2019, type = "weekly")
Get ESPN NFL depth chart by year and team
get_depth_chart(season = 2020, team = 23)
get_depth_chart(season = 2020, team = 23)
season |
Either numeric or character |
team |
team_id or team_abb, can be retrieved via get_nfl_teams() |
Returns a tibble
# Get depth chart for 2017 for Pittsburgh get_depth_chart("2016", team = "PIT")
# Get depth chart for 2017 for Pittsburgh get_depth_chart("2016", team = "PIT")
Get NFL in-game win probabilities for a specific game from ESPN
get_espn_win_prob(game_id)
get_espn_win_prob(game_id)
game_id |
Character string - can be acquired from the website of a specific game, or from espnscrapeR::get_nfl_schedule() |
Returns a tibble
# Get win prob from specific game get_espn_win_prob(game_id = "401030956")
# Get win prob from specific game get_espn_win_prob(game_id = "401030956")
Get ESPN's WR metrics from FiveThirtyEight
get_espn_wr_metrics()
get_espn_wr_metrics()
tibble
raw_metrics <- espnscrapeR::get_espn_wr_metrics() dplyr::glimpse(raw_metrics)
raw_metrics <- espnscrapeR::get_espn_wr_metrics() dplyr::glimpse(raw_metrics)
Get NFL boxscore for a specific game from ESPN's API
get_nfl_boxscore(game_id)
get_nfl_boxscore(game_id)
game_id |
character |
Returns a tibble
# Get NFL play-by-play for a specific game get_nfl_boxscore(game_id = "300912027")
# Get NFL play-by-play for a specific game get_nfl_boxscore(game_id = "300912027")
Get NFL boxscore for players for a specific game from ESPN's API
get_nfl_boxscore_players(game_id)
get_nfl_boxscore_players(game_id)
game_id |
character |
Returns a tibble
# Get NFL play-by-play for a specific game get_nfl_boxscore_players(game_id = "300912027")
# Get NFL play-by-play for a specific game get_nfl_boxscore_players(game_id = "300912027")
Get NFL odds for a specific game from ESPN's API
get_nfl_odds(game_id)
get_nfl_odds(game_id)
game_id |
character |
Returns a tibble
# Get odds from a specific game get_nfl_odds(game_id = "400791550")
# Get odds from a specific game get_nfl_odds(game_id = "400791550")
Get NFL play-by-play for a specific game from ESPN's API
get_nfl_pbp(game_id)
get_nfl_pbp(game_id)
game_id |
character |
Returns a tibble
# Get NFL play-by-play for a specific game get_nfl_pbp(game_id = "300912027")
# Get NFL play-by-play for a specific game get_nfl_pbp(game_id = "300912027")
Get ESPN QBR for NFL football
get_nfl_qbr(season = 2020, week = NA, season_type = "Regular")
get_nfl_qbr(season = 2020, week = NA, season_type = "Regular")
season |
Either numeric or character |
week |
Either NA to return season or week 1 to 4 for playoffs or 1 to 17 for regular |
season_type |
Character - either "Regular" or "Playoffs" |
Returns a tibble
# Get ALL Playoff QBR from 2016 season get_nfl_qbr("2016", season_type = "Playoffs", week = NA) # Get Regular season QBR for week 4 of 2019 get_nfl_qbr("2019", season_type = "Regular", week = 4)
# Get ALL Playoff QBR from 2016 season get_nfl_qbr("2016", season_type = "Playoffs", week = NA) # Get Regular season QBR for week 4 of 2019 get_nfl_qbr("2019", season_type = "Regular", week = 4)
Get ESPN QBR for NFL football
get_nfl_qbr_helper(raw_json, week, season, season_type)
get_nfl_qbr_helper(raw_json, week, season, season_type)
week |
Either NA to return season or week 1 to 4 for playoffs or 1 to 17 for regular |
season |
Either numeric or character |
season_type |
Character - either "Regular" or "Playoffs" |
Returns a tibble
Get NFL schedule for a specific year from ESPN's API
get_nfl_schedule(season)
get_nfl_schedule(season)
season |
Either numeric or character |
Returns a tibble
# Get all games from 2018 season, note that this will have some overlap # between seasons, for example 2018 returns 2018-01-01 to 2018-12-31 get_nfl_schedule(season = "2018")
# Get all games from 2018 season, note that this will have some overlap # between seasons, for example 2018 returns 2018-01-01 to 2018-12-31 get_nfl_schedule(season = "2018")
Get NFL standings for a specific season from ESPN's API
get_nfl_standings(season = 2019, quiet = FALSE)
get_nfl_standings(season = 2019, quiet = FALSE)
season |
Either numeric or character |
Returns a tibble
# Get standings from 2018 season get_nfl_standings(season = "2018") # Get standings from 2010 season get_nfl_standings(2010)
# Get standings from 2018 season get_nfl_standings(season = "2018") # Get standings from 2010 season get_nfl_standings(2010)
Return all NFL teams with their name, abbreviation,
get_nfl_teams()
get_nfl_teams()
tibble
get_nfl_teams()
get_nfl_teams()
Get some of Lee Sharpe's datasets from GitHub
get_sharpe_data(dataset = "games")
get_sharpe_data(dataset = "games")
dataset |
Character only, one of "airports", "closing_lines", "draft_picks", "draft_values", "games", "logos", "pff_pfr_map_v1", "positions", "rosters", "sc_lines", "standings", "teamcolors", "teams", "trades", "win_totals" |
tibble
# Get NFL games and their outcomes get_sharpe_data(dataset = "games") # Get team abbreviations/names/etc by year get_sharpe_data(dataset = "teams")
# Get NFL games and their outcomes get_sharpe_data(dataset = "games") # Get team abbreviations/names/etc by year get_sharpe_data(dataset = "teams")
Apply 'hulk' palette to specific columns in a gt table. The hulk names comes from the idea of a divergin purple and green theme that is colorblind safe and visually appealing. It is a useful alternative to the red/green palette.
gt_hulk_color(gt_object, ..., domain = NULL, trim = FALSE, reverse = FALSE)
gt_hulk_color(gt_object, ..., domain = NULL, trim = FALSE, reverse = FALSE)
gt_object |
An existing gt table object |
... |
columns to apply color to |
trim |
trim the palette to give less intense maximal colors |
reverse |
reverse the color palette. The default is green = high and purple = low, but reverse = TRUE will make purple high and green low. |
Returns a gt table
# basic use mtcars |> head() |> gt::gt() |> gt_hulk_color(mpg) mtcars |> head() |> gt::gt() |> # trim gives small range of colors gt_hulk_color(mpg:disp, trim = TRUE) # option to reverse the color palette mtcars |> head() |> gt::gt() |> # trim gives small range of colors gt_hulk_color(mpg:disp, rev = TRUE)
# basic use mtcars |> head() |> gt::gt() |> gt_hulk_color(mpg) mtcars |> head() |> gt::gt() |> # trim gives small range of colors gt_hulk_color(mpg:disp, trim = TRUE) # option to reverse the color palette mtcars |> head() |> gt::gt() |> # trim gives small range of colors gt_hulk_color(mpg:disp, rev = TRUE)
Apply FiveThirtyEight theme to a gt table
gt_theme_538(data, ...)
gt_theme_538(data, ...)
data |
An existing gt table object |
... |
Optional additional arguments to gt::table_options() |
Returns a tibble
Apply ESPN theme to a gt table
gt_theme_espn(data, ...)
gt_theme_espn(data, ...)
data |
An existing gt table object |
... |
Optional additional arguments to gt::table_options() |
Returns a tibble
Scrape NFL stats from ESPN
scrape_espn_stats(season = 2019, stats = "receiving", season_type = "Regular")
scrape_espn_stats(season = 2019, stats = "receiving", season_type = "Regular")
season |
character or numeric - greater than 1990 |
stats |
character - either receiving, passing, or rushing |
season_type |
character - either Regular or Playoffs |
tibble
scrape_espn_stats(season = 2000, stats = "passing")
scrape_espn_stats(season = 2000, stats = "passing")
Scrape ESPN Pass/Run Block/Rush Win Rates ratings for a specific season from ESPN's site
scrape_espn_win_rate(season = 2022)
scrape_espn_win_rate(season = 2022)
Returns a tibble
# Get off and def pass/run win rates scrape_espn_win_rate()
# Get off and def pass/run win rates scrape_espn_win_rate()
Scrape ESPN FPI ratings for a specific season from ESPN's site
scrape_fpi(season = 2020, stat = "FPI")
scrape_fpi(season = 2020, stat = "FPI")
season |
Either numeric or character |
stat |
One of 'FPI', 'EFF' or 'PROJ' |
Returns a tibble
# Get team offensive and defensive efficiency from 2020 season scrape_fpi(2020, stat = "EFF")
# Get team offensive and defensive efficiency from 2020 season scrape_fpi(2020, stat = "EFF")
Scrapes QBR tables for NFL QBs by specific week or at season level.
scrape_nfl_qbr(season = 2019, week = NA, season_type = "Regular")
scrape_nfl_qbr(season = 2019, week = NA, season_type = "Regular")
season |
Either numeric or character. Must be between 2006 and current season. |
week |
Either NA to return season, week 1 to 4 for playoffs, or 1 to 17 for regular season. |
season_type |
Character - either "Regular" or "Playoffs" |
This function supercedes 'get_nfl_qbr' due to the ESPN API altering past data.
Returns a tibble
# Scrape ALL Playoff QBR from 2016 season scrape_nfl_qbr("2016", season_type = "Playoffs", week = NA) # Scrape Regular season QBR for week 4 of 2019 scrape_nfl_qbr("2019", season_type = "Regular", week = 4)
# Scrape ALL Playoff QBR from 2016 season scrape_nfl_qbr("2016", season_type = "Playoffs", week = NA) # Scrape Regular season QBR for week 4 of 2019 scrape_nfl_qbr("2019", season_type = "Regular", week = 4)
Scrape NFL standings for a specific season from ESPN's site
scrape_nfl_standings(season, add_superbowls = FALSE)
scrape_nfl_standings(season, add_superbowls = FALSE)
season |
Either numeric or character |
add_superbowls |
Join superbowl winners (appropriate for historical data or after season over) |
Returns a tibble
# Get standings from 2018 season scrape_nfl_standings(season = "2018") # Get standings from 2010 season scrape_nfl_standings(2000, add_superbowls = TRUE)
# Get standings from 2018 season scrape_nfl_standings(season = "2018") # Get standings from 2010 season scrape_nfl_standings(2000, add_superbowls = TRUE)
Scrape NFL weekly outcomes by week
scrape_nfl_weekly_standings(season = 2020, tidy = FALSE)
scrape_nfl_weekly_standings(season = 2020, tidy = FALSE)
season |
character or numeric - greater than 1990 |
tidy |
logical - either TRUE to stack data by game/week or FALSE to return table as is |
tibble
# Here we run w/ tidy = FALSE to get the exact table from PFR scrape_nfl_weekly_standings(season = 2020, tidy = FALSE) # Here we scrape the outcome and stack the games on top of eachother scrape_nfl_weekly_standings(season = 2020, tidy = TRUE)
# Here we run w/ tidy = FALSE to get the exact table from PFR scrape_nfl_weekly_standings(season = 2020, tidy = FALSE) # Here we scrape the outcome and stack the games on top of eachother scrape_nfl_weekly_standings(season = 2020, tidy = TRUE)
Scrape NFL superbowl winners for all years
scrape_superbowls()
scrape_superbowls()
Returns a tibble
# Get superbowls scrape_superbowls()
# Get superbowls scrape_superbowls()
Please note that the column names are identical between offense/defense and you should reference the 'role' column for offensive or defensive stats.
scrape_team_stats_nfl(season = 2019, stats = "passing", role = "offense")
scrape_team_stats_nfl(season = 2019, stats = "passing", role = "offense")
season |
character or numeric - greater than 1971, note that some data is missing for earlier seasons. |
stats |
character - either "passing", "rushing", "receiving", "scoring", "downs" |
role |
character - "offense" or "defense" |
tibble
# Get the NFL.com game-level stats for offense in 2018 scrape_team_stats_nfl(season = 2018, stats = "passing", role = "offense") # Get the NFL.com team-level passing stats for defense in 2014 scrape_team_stats_nfl(season = "2014", stats = "rushing", role = "defense")
# Get the NFL.com game-level stats for offense in 2018 scrape_team_stats_nfl(season = 2018, stats = "passing", role = "offense") # Get the NFL.com team-level passing stats for defense in 2014 scrape_team_stats_nfl(season = "2014", stats = "rushing", role = "defense")
Scrape weekly NFL leaders stats from ESPN
scrape_weekly_leaders(season = 2019, week = 1, stats = "passing")
scrape_weekly_leaders(season = 2019, week = 1, stats = "passing")
season |
character or numeric - greater than 2002 |
week |
character or numeric - 1 to 17 for regular season |
stats |
character - either receiving, passing, or rushing |
tibble
scrape_weekly_leaders(season = 2002, stats = "passing", week = 1)
scrape_weekly_leaders(season = 2002, stats = "passing", week = 1)