View source: R/aggregate_game_stats.R
calculate_player_stats | R Documentation |
This function was deprecated because we have a new, much better and
harmonized approach in calculate_stats()
.
Build columns that aggregate official passing, rushing, and receiving stats either at the game level or at the level of the entire data frame passed.
calculate_player_stats(pbp, weekly = FALSE)
pbp |
A Data frame of NFL play-by-play data typically loaded with
|
weekly |
If |
A data frame including the following columns (all ID columns are decoded to the gsis ID format):
ID of the player. Use this to join to other sources.
Name of the player
Full name of the player
Position of the player
Position group of the player
URL to a player headshot image
The number of games where the player recorded passing, rushing or receiving stats.
Most recent team player appears in pbp
with.
Season if weekly
is TRUE
Week if weekly
is TRUE
REG
or POST
if weekly
is TRUE
The player's opponent team if weekly
is TRUE
The number of completed passes.
The number of pass attempts as defined by the NFL.
Yards gained on pass plays.
The number of passing touchdowns.
The number of interceptions thrown.
The Number of times sacked.
Yards lost on sack plays.
The number of sacks with a fumble.
The number of sacks with a lost fumble.
Passing air yards (includes incomplete passes).
Yards after the catch gained on plays in which player was the passer (this is an unofficial stat and may differ slightly between different sources).
First downs on pass attempts.
Total expected points added on pass attempts and sacks.
NOTE: this uses the variable qb_epa
, which gives QB credit for EPA for up
to the point where a receiver lost a fumble after a completed catch and makes
EPA work more like passing yards on plays with fumbles.
Two-point conversion passes.
Passing Air Conversion Ratio. PACR = passing_yards
/ passing_air_yards
Adjusted EPA + CPOE composite based on coefficients which best predict adjusted EPA/play in the following year.
The number of official rush attempts (incl. scrambles and kneel downs). Rushes after a lateral reception don't count as carry.
Yards gained when rushing with the ball (incl. scrambles and kneel downs). Also includes yards gained after obtaining a lateral on a play that started with a rushing attempt.
The number of rushing touchdowns (incl. scrambles). Also includes touchdowns after obtaining a lateral on a play that started with a rushing attempt.
The number of rushes with a fumble.
The number of rushes with a lost fumble.
First downs on rush attempts (incl. scrambles).
Expected points added on rush attempts (incl. scrambles and kneel downs).
Two-point conversion rushes
The number of pass receptions. Lateral receptions officially don't count as reception.
The number of pass plays where the player was the targeted receiver.
Yards gained after a pass reception. Includes yards gained after receiving a lateral on a play that started as a pass play.
The number of touchdowns following a pass reception. Also includes touchdowns after receiving a lateral on a play that started as a pass play.
Receiving air yards (incl. incomplete passes).
Yards after the catch gained on plays in which player was receiver (this is an unofficial stat and may differ slightly between different sources).
The number of fumbles after a pass reception.
The number of fumbles lost after a pass reception.
Two-point conversion receptions
Receiver Air Conversion Ratio. RACR = receiving_yards
/ receiving_air_yards
The share of targets of the player in all targets of his team
The share of receiving_air_yards of the player in all air_yards of his team
Weighted Opportunity Rating. WOPR = 1.5 × target_share
+ 0.7 × air_yards_share
Standard fantasy points.
PPR fantasy points.
The function load_player_stats()
and the corresponding examples
on the nflfastR website
try({# to avoid CRAN test problems
pbp <- nflfastR::load_pbp(2020)
weekly <- calculate_player_stats(pbp, weekly = TRUE)
dplyr::glimpse(weekly)
overall <- calculate_player_stats(pbp, weekly = FALSE)
dplyr::glimpse(overall)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.