calculate_stats function

Calculate NFL Stats

Calculate NFL Stats

Compute various NFL stats based off nflverse Play-by-Play data.

calculate_stats( seasons = nflreadr::most_recent_season(), summary_level = c("season", "week"), stat_type = c("player", "team"), season_type = c("REG", "POST", "REG+POST") )

Arguments

  • seasons: A numeric vector of 4-digit years associated with given NFL seasons - defaults to latest season. If set to TRUE, returns all available data since 1999.
  • summary_level: Summarize stats by "season" or "week".
  • stat_type: Calculate "player" level stats or "team" level stats.
  • season_type: One of "REG", "POST", or "REG+POST". Filters data to regular season ("REG"), post season ("POST") or keeps all data. Only applied if summary_level == "season".

Returns

A tibble of player/team stats summarized by season/week.

Examples

try({# to avoid CRAN test problems stats <- calculate_stats(2023, "season", "player") dplyr::glimpse(stats) })

See Also

nfl_stats_variables for a description of all variables.

https://www.nflfastr.com/articles/stats_variables.html for a searchable table of the stats variable descriptions.

  • Maintainer: Ben Baldwin
  • License: MIT + file LICENSE
  • Last published: 2024-11-26