### Install nflfastR from CRAN Source: https://github.com/nflverse/nflfastr/blob/master/README.md Standard installation method for the stable version of the nflfastR package from the CRAN repository. ```R install.packages("nflfastR") ``` -------------------------------- ### Install nflfastR Development Version Source: https://github.com/nflverse/nflfastr/blob/master/README.md Methods to install the latest development version of nflfastR, either via the pak package or the nflverse R-universe repository. ```R if (!require("pak")) install.packages("pak") pak::pak("nflverse/nflfastR") ``` ```R install.packages("nflfastR", repos = c("https://nflverse.r-universe.dev", getOption("repos"))) ``` -------------------------------- ### Build Custom Play-by-Play Datasets Source: https://context7.com/nflverse/nflfastr/llms.txt Demonstrates the use of build_nflfastR_pbp to scrape and process raw data for specific games, including parallel processing setup for improved performance. ```r library(nflfastR) library(dplyr) # Enable parallel processing for faster scraping future::plan("multisession") # Build pbp for specific games using game IDs pbp <- build_nflfastR_pbp(c("2023_01_DET_KC", "2023_01_BAL_HOU")) # Build pbp from schedule data schedules <- load_schedules(2023) week1_games <- schedules %>% filter(week == 1) %>% slice_head(n = 3) pbp_week1 <- build_nflfastR_pbp(week1_games) # Analyze the built data red_zone_efficiency <- pbp %>% filter(yardline_100 <= 20, !is.na(epa)) %>% group_by(posteam) %>% summarise( red_zone_plays = n(), touchdowns = sum(touchdown, na.rm = TRUE), avg_epa = mean(epa), td_rate = touchdowns / red_zone_plays ) print(red_zone_efficiency) # Clean up parallel workers future::plan("sequential") ``` -------------------------------- ### Load Aggregated Player Statistics Source: https://context7.com/nflverse/nflfastr/llms.txt Shows how to retrieve season-level or weekly player statistics using load_player_stats. It includes an example of identifying top fantasy performers. ```r library(nflfastR) library(dplyr) # Load season-level player stats player_stats_2023 <- load_player_stats(2023) # Load weekly player stats weekly_stats <- load_player_stats(2023, stat_type = "offense") # Find top fantasy performers fantasy_leaders <- player_stats_2023 %>% select(player_name, position, recent_team, passing_yards, passing_tds, rushing_yards, rushing_tds, receptions, receiving_yards, receiving_tds, fantasy_points_ppr) %>% arrange(desc(fantasy_points_ppr)) %>% head(20) print(fantasy_leaders) ``` -------------------------------- ### GET /games/metadata Source: https://github.com/nflverse/nflfastr/blob/master/NEWS.md Retrieves detailed metadata for NFL games, including betting lines, stadium information, and environmental conditions. ```APIDOC ## GET /games/metadata ### Description Returns a comprehensive list of game-level attributes such as total points, spread lines, and stadium details. ### Method GET ### Endpoint /games/metadata ### Parameters #### Query Parameters - **season** (integer) - Optional - Filter results by NFL season. ### Response #### Success Response (200) - **total** (float) - Total points scored (home_score + away_score). - **spread_line** (float) - Closing spread line (positive: home favored, negative: away favored). - **total_line** (float) - Closing total line. - **div_game** (boolean) - Indicator if the game was a division matchup. - **roof** (string) - Stadium status: 'dome', 'outdoors', 'closed', 'open'. - **surface** (string) - Type of ground surface. - **temp** (integer) - Temperature (only for 'outdoors' or 'open'). - **wind** (integer) - Wind speed in mph (only for 'outdoors' or 'open'). - **home_coach** (string) - Name of the home team coach. - **away_coach** (string) - Name of the away team coach. - **stadium_id** (string) - Unique identifier for the stadium. - **game_stadium** (string) - Name of the stadium. #### Response Example { "total": 45, "spread_line": -3.5, "total_line": 48.5, "div_game": true, "roof": "outdoors", "temp": 65, "wind": 5, "home_coach": "John Doe", "away_coach": "Jane Smith" } ``` -------------------------------- ### Run nflverse System Diagnostic Report Source: https://context7.com/nflverse/nflfastr/llms.txt Executes the nflverse_sitrep() function to generate a system diagnostic report. This report includes version numbers for installed nflverse packages and checks for available updates, aiding in troubleshooting and package management. ```r library(nflfastR) # Run diagnostic report nflverse_sitrep() # Displays versions of all nflverse packages and checks for updates ``` -------------------------------- ### GET /fast_scraper Source: https://context7.com/nflverse/nflfastr/llms.txt Downloads and parses raw NFL play-by-play data for specified game IDs. This is a lower-level function that provides basic variables for custom processing. ```APIDOC ## GET /fast_scraper ### Description Downloads and parses raw NFL play-by-play data for specified games. Adds basic nflfastR variables but excludes advanced metrics. ### Method GET ### Endpoint fast_scraper(game_ids) ### Parameters #### Path Parameters - **game_ids** (vector) - Required - A vector of game IDs (e.g., '2023_01_GB_CHI') to scrape. ### Request Example fast_scraper(c("2023_01_GB_CHI", "2023_02_GB_ATL")) ### Response #### Success Response (200) - **data** (dataframe) - A dataframe containing raw play-by-play data for the requested games. #### Response Example { "play_id": 123, "posteam": "GB", "yardline_100": 75 } ``` -------------------------------- ### Add Expected Pass Rate (xPass) with nflfastR Source: https://context7.com/nflverse/nflfastr/llms.txt This R code snippet demonstrates how to add expected pass rate (xPass) variables to play-by-play data using nflfastR. It includes examples for analyzing team play-calling tendencies and breaking down pass rates by game situation (down and distance). Requires nflfastR and dplyr. ```r library(nflfastR) library(dplyr) # Load pbp with xpass variables pbp <- load_pbp(2023) # Analyze team play-calling tendencies team_tendencies <- pbp %>% filter(!is.na(xpass), rush == 1 | pass == 1) %>% group_by(posteam) %>% summarise( plays = n(), actual_pass_rate = mean(pass), expected_pass_rate = mean(xpass), pass_over_expected = mean(pass_oe) ) %>% arrange(desc(pass_over_expected)) print(team_tendencies) # Analyze by game situation situation_analysis <- pbp %>% filter(!is.na(xpass), down <= 3) %>% group_by(down, ydstogo_bucket = cut(ydstogo, c(0, 3, 7, 10, 20))) %>% summarise( plays = n(), actual_pass_rate = mean(pass), expected_pass_rate = mean(xpass) ) %>% filter(!is.na(ydstogo_bucket)) print(situation_analysis) ``` -------------------------------- ### Load NFL Play-by-Play Data with nflfastR Source: https://context7.com/nflverse/nflfastr/llms.txt Demonstrates how to load historical play-by-play data using load_pbp and perform basic analysis on passing plays. This function is the recommended method for accessing pre-processed NFL data. ```r library(nflfastR) library(dplyr) # Load single season of play-by-play data pbp_2023 <- load_pbp(2023) # Load multiple seasons pbp_multi <- load_pbp(2021:2023) # Filter to passing plays and analyze QB performance passing_plays <- pbp_2023 %>% filter(play_type == "pass", !is.na(epa)) %>% group_by(passer_player_name) %>% summarise( attempts = n(), total_epa = sum(epa), epa_per_play = mean(epa), success_rate = mean(epa > 0) ) %>% filter(attempts >= 200) %>% arrange(desc(epa_per_play)) print(passing_plays) ``` -------------------------------- ### Load and Analyze NFL Schedules Source: https://context7.com/nflverse/nflfastr/llms.txt Explains how to load NFL schedule data with load_schedules and perform analysis on game results and betting spreads. ```r library(nflfastR) library(dplyr) # Load schedules for a season schedules_2023 <- load_schedules(2023) # Find completed games completed_games <- schedules_2023 %>% filter(!is.na(result)) %>% select(game_id, week, away_team, home_team, away_score, home_score, result, spread_line) # Analyze against the spread performance ats_performance <- schedules_2023 %>% filter(!is.na(result)) %>% mutate( home_covered = result > spread_line, away_covered = result < spread_line ) %>% summarise( home_cover_rate = mean(home_covered, na.rm = TRUE), avg_home_margin = mean(result, na.rm = TRUE) ) print(ats_performance) ``` -------------------------------- ### Load PBP with XYAC Variables Source: https://context7.com/nflverse/nflfastr/llms.txt Loads play-by-play data and analyzes receivers' yards after catch (YAC) ability compared to expectations. ```APIDOC ## Load PBP with XYAC Variables ### Description Loads play-by-play data and analyzes receivers' yards after catch (YAC) ability compared to expectations. Identifies receivers who gain more yards than expected after the catch. ### Method `load_pbp()` ### Endpoint N/A (Function within a package) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(nflfastR) library(dplyr) # Load pbp with xyac variables pbp <- load_pbp(2023) # Analyze receivers' YAC ability vs expectation receiver_yac <- pbp %>% filter(complete_pass == 1, !is.na(xyac_mean_yardage)) %>% group_by(receiver_player_name) %>% summarise( receptions = n(), total_yac = sum(yards_after_catch, na.rm = TRUE), expected_yac = sum(xyac_mean_yardage, na.rm = TRUE), yac_over_expected = total_yac - expected_yac, yac_oe_per_reception = yac_over_expected / receptions ) %>% filter(receptions >= 50) %>% arrange(desc(yac_over_expected)) print(head(receiver_yac, 15)) ``` ### Response #### Success Response (200) N/A (Output is printed to console or returned as a data frame) #### Response Example ``` # A tibble: 15 × 6 receiver_player_name receptions total_yac expected_yac yac_over_expected yac_oe_per_reception 1 Tyreek Hill 113 1719 1372 347 3.07 2 Stefon Diggs 107 1414 1175 239 2.23 3 A.J. Brown 106 1311 1108 203 1.92 4 CeeDee Lamb 97 1105 917 188 1.94 5 Amon-Ra St. Brown 107 1076 904 172 1.61 6 Puka Nacua 105 1487 1321 166 1.58 7 Mike Evans 79 1255 1094 161 2.04 8 Garrett Wilson 95 1107 951 156 1.64 9 Nico Collins 59 1097 945 152 2.58 10 DJ Moore 93 1340 1191 149 1.60 11 Keenan Allen 108 1014 868 146 1.35 12 Ja'Marr Chase 81 1033 891 142 1.75 13 Brandon Aiyuk 75 755 616 139 1.85 14 Davante Adams 101 1114 977 137 1.36 15 Chris Olave 84 1113 980 133 1.58 ``` ``` -------------------------------- ### Get Most Recent NFL Season using nflfastR Source: https://context7.com/nflverse/nflfastr/llms.txt Retrieves the most recent NFL season year using the most_recent_season() function. This is useful for dynamically loading the latest available data or for analyses that depend on the current season. ```r library(nflfastR) # Get current season current_season <- most_recent_season() print(paste("Current NFL Season:", current_season)) # Use in data loading recent_pbp <- load_pbp(most_recent_season()) # Load last 3 seasons dynamically last_3_seasons <- load_pbp((most_recent_season() - 2):most_recent_season()) ``` -------------------------------- ### update_pbp_db - Update Play-by-Play Database Source: https://context7.com/nflverse/nflfastr/llms.txt Creates and maintains a play-by-play database table in a connected database. Efficiently handles seasonal updates and supports any DBI-compatible database (DuckDB, SQLite, PostgreSQL, etc.). ```APIDOC ## update_pbp_db - Update Play-by-Play Database ### Description Creates and maintains a play-by-play database table in a connected database. Efficiently handles seasonal updates and supports any DBI-compatible database (DuckDB, SQLite, PostgreSQL, etc.). ### Method `update_pbp_db()` ### Endpoint N/A (Function within a package) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(nflfastR) library(DBI) library(duckdb) # Create a DuckDB database connection con <- dbConnect(duckdb::duckdb(), dbdir = "nfl_pbp.duckdb") # Update database with current season data # Default: updates only most_recent_season() update_pbp_db(con, name = "nflverse_pbp") # Update specific seasons update_pbp_db(con, name = "nflverse_pbp", seasons = 2022:2023) # Rebuild entire database (use TRUE for complete rebuild) # update_pbp_db(con, name = "nflverse_pbp", seasons = TRUE) ``` ### Response #### Success Response (200) N/A (Database is updated in place; no direct output is returned to the console unless an error occurs.) #### Response Example No direct output is returned upon successful execution. The database file (`nfl_pbp.duckdb` in the example) will be updated. ``` -------------------------------- ### POST /calculate_expected_points Source: https://context7.com/nflverse/nflfastr/llms.txt Computes expected points for custom game situations based on provided game state variables. ```APIDOC ## POST /calculate_expected_points ### Description Calculates expected points for custom game situations. Returns probability distributions for scoring outcomes and the expected points value. ### Method POST ### Endpoint calculate_expected_points(situations) ### Parameters #### Request Body - **situations** (dataframe) - Required - A dataframe containing columns: season, home_team, posteam, roof, half_seconds_remaining, yardline_100, down, ydstogo, posteam_timeouts_remaining, defteam_timeouts_remaining. ### Request Example { "season": 2023, "yardline_100": 25, "down": 1, "ydstogo": 10 } ### Response #### Success Response (200) - **ep** (numeric) - The calculated expected points value. - **td_prob** (numeric) - Probability of a touchdown. - **fg_prob** (numeric) - Probability of a field goal. #### Response Example { "ep": 2.45, "td_prob": 0.35, "fg_prob": 0.20 } ``` -------------------------------- ### Update Play-by-Play Database with update_pbp_db Source: https://context7.com/nflverse/nflfastr/llms.txt The update_pbp_db function creates and maintains a play-by-play database table compatible with DBI. It efficiently handles seasonal updates and supports various database backends like DuckDB, SQLite, and PostgreSQL. Requires nflfastR, DBI, and a specific database package (e.g., duckdb). ```r library(nflfastR) library(DBI) library(duckdb) # Create a DuckDB database connection con <- dbConnect(duckdb::duckdb(), dbdir = "nfl_pbp.duckdb") # Update database with current season data # Default: updates only most_recent_season() update_pbp_db(con, name = "nflverse_pbp") # Update specific seasons update_pbp_db(con, name = "nflverse_pbp", seasons = 2022:2023) # Rebuild entire database (use TRUE for complete rebuild) # update_pbp_db(con, name = "nflverse_pbp", seasons = TRUE) ``` -------------------------------- ### Scrape Raw NFL Play-by-Play Data with fast_scraper Source: https://context7.com/nflverse/nflfastr/llms.txt Downloads and parses raw NFL play-by-play data for specified games. It adds basic nflfastR variables but not all advanced metrics. Use `build_nflfastR_pbp()` for complete datasets. Requires the `nflfastR` and `dplyr` packages. Can scrape specific games by ID or games derived from schedule data. ```r library(nflfastR) library(dplyr) # Enable parallel processing future::plan("multisession") # Scrape specific games raw_pbp <- fast_scraper(c("2023_01_GB_CHI", "2023_02_GB_ATL")) # Scrape games from schedule output schedules <- load_schedules(2023) games_to_scrape <- schedules %>% filter(week == 1) %>% slice_head(n = 2) raw_pbp <- fast_scraper(games_to_scrape) # View available columns names(raw_pbp) # Basic analysis of scraped data play_type_summary <- raw_pbp %>% filter(!is.na(play_type)) %>% count(play_type) %>% arrange(desc(n)) print(play_type_summary) future::plan("sequential") ``` -------------------------------- ### POST /calculate_win_probability Source: https://context7.com/nflverse/nflfastr/llms.txt Calculates win probability for custom game situations, including standard and Vegas-adjusted metrics. ```APIDOC ## POST /calculate_win_probability ### Description Calculates win probability for custom game situations. Includes standard win probability and spread-adjusted (Vegas) win probability. ### Method POST ### Endpoint calculate_win_probability(scenarios) ### Parameters #### Request Body - **scenarios** (dataframe) - Required - A dataframe containing game state variables including score_differential and spread_line. ### Request Example { "score_differential": 7, "spread_line": 3, "game_seconds_remaining": 1800 } ### Response #### Success Response (200) - **wp** (numeric) - Standard win probability. - **vegas_wp** (numeric) - Vegas-adjusted win probability. #### Response Example { "wp": 0.65, "vegas_wp": 0.62 } ``` -------------------------------- ### Decode Player IDs using nflfastR Source: https://context7.com/nflverse/nflfastr/llms.txt Demonstrates how to use the decode_player_ids functionality (implicitly within load_pbp) to ensure player IDs are in the standard GSIS format. This is crucial for data integration across different nflverse datasets. ```r library(nflfastR) library(dplyr) # Load pbp data pbp <- load_pbp(2023) # Player IDs are already decoded in load_pbp output # But you can use this on custom data # Check player ID format sample_ids <- pbp %>% filter(!is.na(passer_player_id)) %>% select(passer_player_name, passer_player_id) %>% distinct() %>% head(5) print(sample_ids) # GSIS IDs are 10-character alphanumeric strings like "00-0033873" ``` -------------------------------- ### Compute Expected Points with calculate_expected_points Source: https://context7.com/nflverse/nflfastr/llms.txt Calculates expected points for custom game situations. Takes a data frame with required game state variables and returns probability distributions for each scoring outcome along with the expected points value. Requires `nflfastR` and `dplyr`. ```r library(nflfastR) library(dplyr) # Create custom game situations to analyze situations <- tibble( season = 2023, home_team = "KC", posteam = "KC", roof = "outdoors", half_seconds_remaining = 1800, yardline_100 = c(75, 50, 25, 10, 5), # Different field positions down = 1, ydstogo = 10, posteam_timeouts_remaining = 3, defteam_timeouts_remaining = 3 ) # Calculate expected points ep_results <- calculate_expected_points(situations) # View results ep_summary <- ep_results %>% select(yardline_100, ep, td_prob, fg_prob, opp_td_prob, no_score_prob) print(ep_summary) # Shows how EP increases as team gets closer to the end zone ``` -------------------------------- ### Compute Win Probability with calculate_win_probability Source: https://context7.com/nflverse/nflfastr/llms.txt Calculates win probability for custom game situations. Includes both standard win probability and spread-adjusted (Vegas) win probability that incorporates pre-game point spreads. Requires `nflfastR` and `dplyr`. ```r library(nflfastR) library(dplyr) # Create different game scenarios scenarios <- tibble( receive_2h_ko = 0, # Not receiving 2nd half kickoff home_team = "BUF", posteam = "BUF", score_differential = c(0, 7, 14, -7, -14), # Various score margins half_seconds_remaining = 1800, game_seconds_remaining = 1800, spread_line = 3, # Home team favored by 3 down = 1, ydstogo = 10, yardline_100 = 75, posteam_timeouts_remaining = 3, defteam_timeouts_remaining = 3 ) # Calculate win probabilities wp_results <- calculate_win_probability(scenarios) # Compare standard and Vegas-adjusted WP wp_comparison <- wp_results %>% select(score_differential, spread_line, wp, vegas_wp) %>% mutate( wp = round(wp, 3), vegas_wp = round(vegas_wp, 3), wp_diff = round(vegas_wp - wp, 3) ) print(wp_comparison) # Shows how Vegas line affects win probability calculations ``` -------------------------------- ### add_xpass - Add Expected Pass Rate Source: https://context7.com/nflverse/nflfastr/llms.txt Adds expected dropback probability (xPass) based on game situation. Includes `xpass` (probability of dropback) and `pass_oe` (pass rate over expected). Available for 2006 and later seasons. ```APIDOC ## add_xpass - Add Expected Pass Rate ### Description Adds expected dropback probability (xPass) based on game situation. Includes `xpass` (probability of dropback) and `pass_oe` (pass rate over expected). Available for 2006 and later seasons. ### Method `load_pbp()` (implicitly used to get data with xpass variables) ### Endpoint N/A (Function within a package) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(nflfastR) library(dplyr) # Load pbp with xpass variables pbp <- load_pbp(2023) # Analyze team play-calling tendencies team_tendencies <- pbp %>% filter(!is.na(xpass), rush == 1 | pass == 1) %>% group_by(posteam) %>% summarise( plays = n(), actual_pass_rate = mean(pass), expected_pass_rate = mean(xpass), pass_over_expected = mean(pass_oe) ) %>% arrange(desc(pass_over_expected)) print(team_tendencies) # Analyze by game situation situation_analysis <- pbp %>% filter(!is.na(xpass), down <= 3) %>% group_by(down, ydstogo_bucket = cut(ydstogo, c(0, 3, 7, 10, 20))) %>% summarise( plays = n(), actual_pass_rate = mean(pass), expected_pass_rate = mean(xpass) ) %>% filter(!is.na(ydstogo_bucket)) print(situation_analysis) ``` ### Response #### Success Response (200) N/A (Output is printed to console or returned as a data frame) #### Response Example ``` # A tibble: 32 × 5 posteam plays actual_pass_rate expected_pass_rate pass_over_expected 1 ARI 1088. 0.542 0.514 0.0277 2 ATL 1117. 0.597 0.562 0.0351 3 BAL 1036. 0.456 0.474 -0.0178 4 BUF 1130. 0.586 0.564 0.0217 5 CAR 1069. 0.475 0.497 -0.0218 6 CHI 1077. 0.479 0.494 -0.0152 7 CIN 1116. 0.577 0.560 0.0172 8 CLE 1091. 0.515 0.508 0.00679 9 DAL 1107. 0.557 0.543 0.0137 10 DEN 1084. 0.482 0.487 -0.00509 # ℹ 22 more rows # A tibble: 12 × 4 down ydstogo_bucket plays actual_pass_rate expected_pass_rate 1 1 (0,3] 2012. 0.518 0.543 2 1 (3,7] 1785. 0.575 0.580 3 1 (7,10] 1086. 0.605 0.602 4 1 (10,20] 495. 0.650 0.636 5 2 (0,3] 1960. 0.548 0.570 6 2 (3,7] 1772. 0.592 0.599 7 2 (7,10] 1064. 0.624 0.621 8 2 (10,20] 477. 0.656 0.647 9 3 (0,3] 911. 0.607 0.633 10 3 (3,7] 774. 0.657 0.653 11 3 (7,10] 513. 0.676 0.667 12 3 (10,20] 218. 0.711 0.694 ``` ``` -------------------------------- ### calculate_series_conversion_rates - Compute Series Conversion Rates Source: https://context7.com/nflverse/nflfastr/llms.txt Calculates offensive and defensive series conversion rates. A series begins on 1st and 10, and conversion occurs when the offense earns a new first down or scores a touchdown. ```APIDOC ## calculate_series_conversion_rates - Compute Series Conversion Rates ### Description Calculates offensive and defensive series conversion rates. A series begins on 1st and 10, and conversion occurs when the offense earns a new first down or scores a touchdown. ### Method `calculate_series_conversion_rates()` ### Endpoint N/A (Function within a package) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(nflfastR) library(dplyr) # Load play-by-play data pbp <- load_pbp(2023) # Calculate season-level series conversion rates season_rates <- calculate_series_conversion_rates(pbp, weekly = FALSE) # View offensive efficiency rankings offense_rankings <- season_rates %>% select(season, team, off_n, off_scr, off_td, off_punt, off_to) %>% arrange(desc(off_scr)) print(head(offense_rankings, 10)) # Calculate weekly rates for trend analysis weekly_rates <- calculate_series_conversion_rates(pbp, weekly = TRUE) # Track a team's conversion rate over the season team_trend <- weekly_rates %>% filter(team == "SF") %>% select(week, off_scr, def_scr) %>% mutate( off_scr = round(off_scr, 3), def_scr = round(def_scr, 3) ) print(team_trend) ``` ### Response #### Success Response (200) N/A (Output is printed to console or returned as a data frame) #### Response Example ``` # A tibble: 120 × 10 season team off_n off_scr off_td off_punt off_to def_n def_scr def_td 1 2023 ARI 108. 0.388 15.0 72.0 21.0 108. 0.412 16.0 2 2023 ATL 111. 0.375 14.0 74.0 22.0 111. 0.405 16.0 3 2023 BAL 103. 0.456 20.0 67.0 16.0 103. 0.427 17.0 4 2023 BUF 113. 0.442 27.0 72.0 14.0 113. 0.416 19.0 5 2023 CAR 107. 0.330 13.0 77.0 27.0 107. 0.450 18.0 6 2023 CHI 108. 0.343 16.0 77.0 25.0 108. 0.451 19.0 7 2023 CIN 111. 0.430 21.0 73.0 17.0 111. 0.417 17.0 8 2023 CLE 109. 0.420 17.0 72.0 17.0 109. 0.440 18.0 9 2023 DAL 111. 0.451 27.0 70.0 14.0 111. 0.410 17.0 10 2023 DEN 108. 0.365 15.0 75.0 23.0 108. 0.435 18.0 # ℹ 110 more rows # A tibble: 17 × 3 week off_scr def_scr 1 1 0.667 0.500 2 2 0.600 0.400 3 3 0.600 0.500 4 4 0.700 0.500 5 5 0.600 0.500 6 6 0.600 0.400 7 7 0.700 0.500 8 8 0.700 0.500 9 9 0.600 0.500 10 10 0.600 0.500 11 11 0.700 0.500 12 12 0.700 0.500 13 13 0.700 0.500 14 14 0.700 0.500 15 15 0.700 0.500 16 16 0.700 0.500 17 17 0.700 0.500 ``` ``` -------------------------------- ### NFL Player and Game Statistics Source: https://github.com/nflverse/nflfastr/blob/master/tests/testthat/_snaps/stats/calculate_stats.md This endpoint provides a comprehensive list of statistics available for NFL players and games, including passing, rushing, receiving, defensive, kicking, and punting metrics. ```APIDOC ## GET /api/nfl/stats ### Description Retrieves a detailed list of available NFL statistics, covering player and game-level data across various categories. ### Method GET ### Endpoint /api/nfl/stats ### Parameters This endpoint does not accept any parameters. It returns a static list of all available statistical fields. ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **value** (array) - An array of strings, where each string is a name of an available statistical metric. #### Response Example ```json { "value": [ "season", "week", "team", "season_type", "game_id", "opponent_team", "completions", "attempts", "passing_yards", "passing_tds", "passing_interceptions", "sacks_suffered", "sack_yards_lost", "sack_fumbles", "sack_fumbles_lost", "passing_air_yards", "passing_yards_after_catch", "passing_first_downs", "passing_epa", "passing_cpoe", "passing_2pt_conversions", "passing_10", "passing_16", "passing_20", "passing_40", "carries", "rushing_yards", "rushing_tds", "rushing_fumbles", "rushing_fumbles_lost", "rushing_first_downs", "rushing_epa", "rushing_2pt_conversions", "rushing_10", "rushing_12", "rushing_20", "rushing_40", "receptions", "targets", "receiving_yards", "receiving_tds", "receiving_fumbles", "receiving_fumbles_lost", "receiving_air_yards", "receiving_yards_after_catch", "receiving_first_downs", "receiving_epa", "receiving_2pt_conversions", "receiving_10", "receiving_16", "receiving_20", "receiving_40", "special_teams_tds", "def_tackles_solo", "def_tackles_with_assist", "def_tackle_assists", "def_tackles_for_loss", "def_tackles_for_loss_yards", "def_fumbles_forced", "def_sacks", "def_sack_yards", "def_qb_hits", "def_interceptions", "def_interception_yards", "def_pass_defended", "def_tds", "def_fumbles", "def_safeties", "misc_yards", "fumble_recovery_own", "fumble_recovery_yards_own", "fumble_recovery_opp", "fumble_recovery_yards_opp", "fumble_recovery_tds", "penalties", "penalty_yards", "timeouts", "fumbles_forced_by_opp", "fumbles_not_forced", "fumbles_out_of_bounds", "fumbles_total", "fumbles_lost_total", "punt_returns", "punt_return_yards", "kickoff_returns", "kickoff_return_yards", "fg_made", "fg_att", "fg_missed", "fg_blocked", "fg_long", "fg_pct", "fg_made_0_19", "fg_made_20_29", "fg_made_30_39", "fg_made_40_49", "fg_made_50_59", "fg_made_60_", "fg_missed_0_19", "fg_missed_20_29", "fg_missed_30_39", "fg_missed_40_49", "fg_missed_50_59", "fg_missed_60_", "fg_made_list", "fg_missed_list", "fg_blocked_list", "fg_made_distance", "fg_missed_distance", "fg_blocked_distance", "pat_made", "pat_att", "pat_missed", "pat_blocked", "pat_pct", "gwfg_made", "gwfg_att", "gwfg_missed", "gwfg_blocked", "gwfg_distance", "pt_att", "pt_blocked", "pt_long", "pt_yards", "pt_inside_20", "pt_out_of_bounds", "pt_downed", "pt_touchback", "pt_fair_caught", "pt_returned", "pt_return_yards", "pt_return_tds", "pt_net_yards" ] } ``` ``` -------------------------------- ### Define nflfastR Play-by-Play Schema Source: https://github.com/nflverse/nflfastr/blob/master/tests/testthat/_snaps/build_nflfastR_pbp.md This JSON structure defines the schema for a play-by-play record in nflfastR. It lists the core attributes including game identifiers, play descriptions, and advanced analytical metrics. ```json { "type": "character", "attributes": { "names": { "type": "character", "attributes": {}, "value": ["play_id", "game_id", "posteam", "defteam", "yards_gained", "epa", "wp", "wpa"] } } } ```