Note: There are multiple data sets available at this link. The yearly_player_stats_offense.csv file was utilized for this analysis.
NFL_Data <- read.csv("C:/Users/bsko1/OneDrive/Desktop/Data Visualization Course/Week 5/Assignment 5/NFL_Data_by_Year.csv")
str(NFL_Data)
## 'data.frame': 10856 obs. of 591 variables:
## $ player_id : chr "00-0038389" "00-0031021" "00-0031021" "00-0031021" ...
## $ pfr_player_id : chr "AbanIs00" "AbbrJa00" "AbbrJa00" "AbbrJa00" ...
## $ player_name : chr "Israel Abanikanda" "Jared Abbrederis" "Jared Abbrederis" "Jared Abbrederis" ...
## $ position : chr "RB" "WR" "WR" "WR" ...
## $ position_group : chr "RB" "WR" "WR" "WR" ...
## $ team : chr "NYJ" "DET" "GB" "GB" ...
## $ birth_date : chr "10/5/2002" "12/17/1990" "12/17/1990" "12/17/1990" ...
## $ height : int 70 73 73 73 73 73 73 69 69 69 ...
## $ weight : int 216 195 195 195 195 196 196 203 203 203 ...
## $ college_name : chr "Pittsburgh" "Wisconsin" "Wisconsin" "Wisconsin" ...
## $ college_conference : chr "Atlantic Coast Conference" "" "" "" ...
## $ draft_year : int 2023 2014 2014 2014 2014 0 0 2015 2015 2015 ...
## $ draft_round : int 5 5 5 5 5 0 0 2 2 2 ...
## $ draft_pick : int 143 176 176 176 176 0 0 54 54 54 ...
## $ draft_team : chr "NYJ" "GB" "GB" "GB" ...
## $ rookie_season : int 2023 2014 2014 2014 2014 2011 2011 2015 2015 2015 ...
## $ years_exp : int 3 4 4 4 4 6 6 12 12 12 ...
## $ season : int 2023 2017 2015 2015 2016 2014 2015 2021 2015 2016 ...
## $ games : int 6 0 0 0 0 0 0 17 0 0 ...
## $ games_started : int 0 0 0 0 0 0 0 1 0 0 ...
## $ season_type : chr "REG" "REG" "POST" "REG" ...
## $ status : chr "ACT" "CUT" "CUT" "CUT" ...
## $ shotgun : int 18 7 15 16 2 0 0 69 90 16 ...
## $ no_huddle : int 6 3 9 10 0 0 0 20 1 8 ...
## $ qb_dropback : int 11 7 17 19 2 1 0 49 44 5 ...
## $ qb_scramble : int 0 0 0 0 0 0 0 0 0 0 ...
## $ scrambles : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_attempts : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_attempts_red_zone : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_attempts_gtg : int 0 0 0 0 0 0 0 0 0 0 ...
## $ complete_pass : int 0 0 0 0 0 0 0 0 0 0 ...
## $ complete_pass_red_zone : int 0 0 0 0 0 0 0 0 0 0 ...
## $ complete_pass_gtg : int 0 0 0 0 0 0 0 0 0 0 ...
## $ incomplete_pass : int 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_yards : int 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_air_yards : int 0 0 0 56 0 0 0 0 0 0 ...
## $ comp_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ypa : num 0 0 0 0 0 0 0 0 0 0 ...
## $ ayptarget : num 0.55 6.71 11.4 16.29 4.5 ...
## $ pass_adot : num 0 0 0 0 0 0 0 0 0 0 ...
## $ passer_rating : num 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_touchdown : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_touchdown_red_zone : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_touchdown_gtg : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pass_td_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ interception : int 0 0 1 0 0 0 0 1 2 0 ...
## $ int_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ first_down_pass : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pa_pass_att : int 0 0 0 0 0 0 0 0 0 0 ...
## $ rpo_plays : int 0 0 0 0 0 0 0 0 0 0 ...
## $ rpo_pass_att : int 0 0 0 0 0 0 0 0 0 0 ...
## $ rpo_rush_att : int 0 0 0 0 0 0 0 0 0 0 ...
## $ times_blitzed : int 0 0 0 0 0 0 0 0 0 0 ...
## $ times_hurried : int 0 0 0 0 0 0 0 0 0 0 ...
## $ times_hit : int 0 0 0 0 0 0 0 0 0 0 ...
## $ times_pressured : int 0 0 0 0 0 0 0 0 0 0 ...
## $ times_pressured_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ on_tgt_throws : int 0 0 0 0 0 0 0 0 0 0 ...
## $ on_tgt_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_drops : int 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_drop_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_bad_throws : int 0 0 0 0 0 0 0 0 0 0 ...
## $ passing_bad_throw_pct : num 0 0 0 0 0 0 0 0 0 0 ...
## $ batted_balls : int 0 0 0 0 0 0 0 0 0 0 ...
## $ throwaways : int 0 0 0 0 0 0 0 0 0 0 ...
## $ spikes : int 0 0 0 0 0 0 0 0 0 0 ...
## $ pocket_time : num 0 0 0 0 0 0 0 0 0 0 ...
## $ targets : int 11 7 15 17 2 1 0 48 42 5 ...
## $ targets_red_zone : int 0 2 2 2 0 0 0 7 8 1 ...
## $ targets_gtg : int 0 0 0 1 0 0 0 0 1 0 ...
## $ receptions : int 7 3 6 10 1 1 0 35 31 5 ...
## $ receptions_red_zone : int 0 1 0 1 0 0 0 5 7 1 ...
## $ receptions_gtg : int 0 0 0 0 0 0 0 0 1 0 ...
## $ receiving_yards : int 43 44 69 143 8 3 0 272 258 57 ...
## $ receiving_air_yards : int 6 47 171 277 9 -4 0 41 16 3 ...
## $ receiving_air_yards_red_zone : int 0 11 34 8 0 0 0 -18 32 3 ...
## $ receiving_air_yards_gtg : int 0 0 0 3 0 0 0 0 1 0 ...
## $ yards_after_catch : int 46 28 27 27 2 7 0 275 260 54 ...
## $ yards_after_contact_rec : num 6.6 0 0 0 0 0 0 7.7 0 0 ...
## $ ybc_r : num -0.4 0 0 0 0 0 0 -0.1 0 0 ...
## $ yptarget : num 3.91 6.29 4.6 8.41 4 3 0 5.67 6.14 11.4 ...
## $ ypr : num 6.14 14.67 11.5 14.3 8 ...
## $ rec_adot : num 0.545 6.714 11.4 16.294 4.5 ...
## $ receiving_touchdown : int 0 0 0 0 0 0 0 1 4 1 ...
## $ receiving_touchdown_red_zone : int 0 0 0 0 0 0 0 0 2 1 ...
## $ receiving_touchdown_gtg : int 0 0 0 0 0 0 0 0 0 0 ...
## $ rec_td_pct : num 0 0 0 0 0 0 0 0.021 0.095 0.2 ...
## $ receiving_drop : int 2 0 0 0 0 0 0 2 0 0 ...
## $ receiving_drop_pct : num 0.182 0 0 0 0 0 0 0.038 0 0 ...
## $ receiving_broken_tackles : num 0 0 0 0 0 0 0 7.6 0 0 ...
## $ receiving_int : int 0 0 0 0 0 0 0 1 0 0 ...
## $ receiving_rat : num 71.4 0 0 0 0 0 0 83 0 0 ...
## $ rush_attempts : int 22 0 0 0 0 0 2 47 155 18 ...
## $ rush_attempts_red_zone : int 0 0 0 0 0 0 0 8 12 2 ...
## $ rush_attempts_gtg : int 0 0 0 0 0 0 0 2 2 0 ...
## $ rushing_yards : int 70 0 0 0 0 0 34 130 585 101 ...
## $ ypc : num 3.18 0 0 0 0 0 17 2.77 3.77 5.61 ...
## $ ybc_att : num 2.1 0 0 0 0 0 0 1.7 0 0 ...
## $ yards_after_contact_att : num 1.1 0 0 0 0 0 0 1.6 0 0 ...
## [list output truncated]
colSums(is.na(NFL_Data))
## player_id pfr_player_id
## 0 0
## player_name position
## 0 0
## position_group team
## 0 0
## birth_date height
## 0 0
## weight college_name
## 0 0
## college_conference draft_year
## 0 0
## draft_round draft_pick
## 0 0
## draft_team rookie_season
## 0 0
## years_exp season
## 0 0
## games games_started
## 0 0
## season_type status
## 0 0
## shotgun no_huddle
## 0 0
## qb_dropback qb_scramble
## 0 0
## scrambles pass_attempts
## 0 0
## pass_attempts_red_zone pass_attempts_gtg
## 0 0
## complete_pass complete_pass_red_zone
## 0 0
## complete_pass_gtg incomplete_pass
## 0 0
## passing_yards passing_air_yards
## 0 0
## comp_pct ypa
## 0 0
## ayptarget pass_adot
## 0 0
## passer_rating pass_touchdown
## 0 0
## pass_touchdown_red_zone pass_touchdown_gtg
## 0 0
## pass_td_pct interception
## 0 0
## int_pct first_down_pass
## 0 0
## pa_pass_att rpo_plays
## 0 0
## rpo_pass_att rpo_rush_att
## 0 0
## times_blitzed times_hurried
## 0 0
## times_hit times_pressured
## 0 0
## times_pressured_pct on_tgt_throws
## 0 0
## on_tgt_pct passing_drops
## 0 0
## passing_drop_pct passing_bad_throws
## 0 0
## passing_bad_throw_pct batted_balls
## 0 0
## throwaways spikes
## 0 0
## pocket_time targets
## 0 0
## targets_red_zone targets_gtg
## 0 0
## receptions receptions_red_zone
## 0 0
## receptions_gtg receiving_yards
## 0 0
## receiving_air_yards receiving_air_yards_red_zone
## 0 0
## receiving_air_yards_gtg yards_after_catch
## 0 0
## yards_after_contact_rec ybc_r
## 0 0
## yptarget ypr
## 0 0
## rec_adot receiving_touchdown
## 0 0
## receiving_touchdown_red_zone receiving_touchdown_gtg
## 0 0
## rec_td_pct receiving_drop
## 0 0
## receiving_drop_pct receiving_broken_tackles
## 0 0
## receiving_int receiving_rat
## 0 0
## rush_attempts rush_attempts_red_zone
## 0 0
## rush_attempts_gtg rushing_yards
## 0 0
## ypc ybc_att
## 0 0
## yards_after_contact_att rush_touchdown
## 0 0
## rush_touchdown_red_zone rush_touchdown_gtg
## 0 0
## rush_td_pct first_down_rush
## 0 0
## rushing_broken_tackles_att offense_snaps
## 0 0
## team_offense_snaps offense_pct
## 0 0
## third_down_converted third_down_failed
## 0 0
## fourth_down_converted fourth_down_failed
## 0 0
## safety tackled_for_loss
## 0 0
## broken_tackles touches
## 0 0
## total_yards total_tds
## 0 0
## td_pct yptouch
## 0 0
## ybc yards_after_contact
## 0 0
## x1d fantasy_points_standard
## 0 0
## fantasy_points_half_ppr fantasy_points_ppr
## 0 0
## trend_shotgun trend_no_huddle
## 0 0
## trend_qb_dropback trend_qb_scramble
## 0 0
## trend_scrambles trend_pass_attempts
## 0 0
## trend_pass_attempts_red_zone trend_pass_attempts_gtg
## 0 0
## trend_complete_pass trend_complete_pass_red_zone
## 0 0
## trend_complete_pass_gtg trend_incomplete_pass
## 0 0
## trend_passing_yards trend_passing_air_yards
## 0 0
## trend_comp_pct trend_ypa
## 0 0
## trend_ayptarget trend_pass_adot
## 0 0
## trend_passer_rating trend_pass_touchdown
## 0 0
## trend_pass_touchdown_red_zone trend_pass_touchdown_gtg
## 0 0
## trend_pass_td_pct trend_interception
## 0 0
## trend_int_pct trend_first_down_pass
## 0 0
## trend_pa_pass_att trend_rpo_plays
## 0 0
## trend_rpo_pass_att trend_rpo_rush_att
## 0 0
## trend_times_blitzed trend_times_hurried
## 0 0
## trend_times_hit trend_times_pressured
## 0 0
## trend_times_pressured_pct trend_on_tgt_throws
## 0 0
## trend_on_tgt_pct trend_passing_drops
## 0 0
## trend_passing_drop_pct trend_passing_bad_throws
## 0 0
## trend_passing_bad_throw_pct trend_batted_balls
## 0 0
## trend_throwaways trend_spikes
## 0 0
## trend_pocket_time trend_targets
## 0 0
## trend_targets_red_zone trend_targets_gtg
## 0 0
## trend_receptions trend_receptions_red_zone
## 0 0
## trend_receptions_gtg trend_receiving_yards
## 0 0
## trend_receiving_air_yards trend_receiving_air_yards_red_zone
## 0 0
## trend_receiving_air_yards_gtg trend_yards_after_catch
## 0 0
## trend_yards_after_contact_rec trend_ybc_r
## 0 0
## trend_yptarget trend_ypr
## 0 0
## trend_rec_adot trend_receiving_touchdown
## 0 0
## trend_receiving_touchdown_red_zone trend_receiving_touchdown_gtg
## 0 0
## trend_rec_td_pct trend_receiving_drop
## 0 0
## trend_receiving_drop_pct trend_receiving_broken_tackles
## 0 0
## trend_receiving_int trend_receiving_rat
## 0 0
## trend_rush_attempts trend_rush_attempts_red_zone
## 0 0
## trend_rush_attempts_gtg trend_rushing_yards
## 0 0
## trend_ypc trend_ybc_att
## 0 0
## trend_yards_after_contact_att trend_rush_touchdown
## 0 0
## trend_rush_touchdown_red_zone trend_rush_touchdown_gtg
## 0 0
## trend_rush_td_pct trend_first_down_rush
## 0 0
## trend_rushing_broken_tackles_att trend_offense_snaps
## 0 0
## trend_team_offense_snaps trend_offense_pct
## 0 0
## trend_third_down_converted trend_third_down_failed
## 0 0
## trend_fourth_down_converted trend_fourth_down_failed
## 0 0
## trend_safety trend_tackled_for_loss
## 0 0
## trend_broken_tackles trend_touches
## 0 0
## trend_total_yards trend_total_tds
## 0 0
## trend_td_pct trend_yptouch
## 0 0
## trend_ybc trend_yards_after_contact
## 0 0
## trend_x1d trend_fantasy_points_standard
## 0 0
## trend_fantasy_points_half_ppr trend_fantasy_points_ppr
## 0 0
## avg_shotgun avg_no_huddle
## 0 0
## avg_qb_dropback avg_qb_scramble
## 0 0
## avg_scrambles avg_pass_attempts
## 0 0
## avg_pass_attempts_red_zone avg_pass_attempts_gtg
## 0 0
## avg_complete_pass avg_complete_pass_red_zone
## 0 0
## avg_complete_pass_gtg avg_incomplete_pass
## 0 0
## avg_passing_yards avg_passing_air_yards
## 0 0
## avg_comp_pct avg_ypa
## 0 0
## avg_ayptarget avg_pass_adot
## 0 0
## avg_passer_rating avg_pass_touchdown
## 0 0
## avg_pass_touchdown_red_zone avg_pass_touchdown_gtg
## 0 0
## avg_pass_td_pct avg_interception
## 0 0
## avg_int_pct avg_first_down_pass
## 0 0
## avg_pa_pass_att avg_rpo_plays
## 0 0
## avg_rpo_pass_att avg_rpo_rush_att
## 0 0
## avg_times_blitzed avg_times_hurried
## 0 0
## avg_times_hit avg_times_pressured
## 0 0
## avg_times_pressured_pct avg_on_tgt_throws
## 0 0
## avg_on_tgt_pct avg_passing_drops
## 0 0
## avg_passing_drop_pct avg_passing_bad_throws
## 0 0
## avg_passing_bad_throw_pct avg_batted_balls
## 0 0
## avg_throwaways avg_spikes
## 0 0
## avg_pocket_time avg_targets
## 0 0
## avg_targets_red_zone avg_targets_gtg
## 0 0
## avg_receptions avg_receptions_red_zone
## 0 0
## avg_receptions_gtg avg_receiving_yards
## 0 0
## avg_receiving_air_yards avg_receiving_air_yards_red_zone
## 0 0
## avg_receiving_air_yards_gtg avg_yards_after_catch
## 0 0
## avg_yards_after_contact_rec avg_ybc_r
## 0 0
## avg_yptarget avg_ypr
## 0 0
## avg_rec_adot avg_receiving_touchdown
## 0 0
## avg_receiving_touchdown_red_zone avg_receiving_touchdown_gtg
## 0 0
## avg_rec_td_pct avg_receiving_drop
## 0 0
## avg_receiving_drop_pct avg_receiving_broken_tackles
## 0 0
## avg_receiving_int avg_receiving_rat
## 0 0
## avg_rush_attempts avg_rush_attempts_red_zone
## 0 0
## avg_rush_attempts_gtg avg_rushing_yards
## 0 0
## avg_ypc avg_ybc_att
## 0 0
## avg_yards_after_contact_att avg_rush_touchdown
## 0 0
## avg_rush_touchdown_red_zone avg_rush_touchdown_gtg
## 0 0
## avg_rush_td_pct avg_first_down_rush
## 0 0
## avg_rushing_broken_tackles_att avg_offense_snaps
## 0 0
## avg_team_offense_snaps avg_offense_pct
## 0 0
## avg_third_down_converted avg_third_down_failed
## 0 0
## avg_fourth_down_converted avg_fourth_down_failed
## 0 0
## avg_safety avg_tackled_for_loss
## 0 0
## avg_broken_tackles avg_touches
## 0 0
## avg_total_yards avg_total_tds
## 0 0
## avg_td_pct avg_yptouch
## 0 0
## avg_ybc avg_yards_after_contact
## 0 0
## avg_x1d avg_fantasy_points_standard
## 0 0
## avg_fantasy_points_half_ppr avg_fantasy_points_ppr
## 0 0
## rel_to_avg_shotgun rel_to_avg_no_huddle
## 0 0
## rel_to_avg_qb_dropback rel_to_avg_qb_scramble
## 0 0
## rel_to_avg_scrambles rel_to_avg_pass_attempts
## 0 0
## rel_to_avg_pass_attempts_red_zone rel_to_avg_pass_attempts_gtg
## 0 0
## rel_to_avg_complete_pass rel_to_avg_complete_pass_red_zone
## 0 0
## rel_to_avg_complete_pass_gtg rel_to_avg_incomplete_pass
## 0 0
## rel_to_avg_passing_yards rel_to_avg_passing_air_yards
## 0 0
## rel_to_avg_comp_pct rel_to_avg_ypa
## 0 0
## rel_to_avg_ayptarget rel_to_avg_pass_adot
## 0 0
## rel_to_avg_passer_rating rel_to_avg_pass_touchdown
## 0 0
## rel_to_avg_pass_touchdown_red_zone rel_to_avg_pass_touchdown_gtg
## 0 0
## rel_to_avg_pass_td_pct rel_to_avg_interception
## 0 0
## rel_to_avg_int_pct rel_to_avg_first_down_pass
## 0 0
## rel_to_avg_pa_pass_att rel_to_avg_rpo_plays
## 0 0
## rel_to_avg_rpo_pass_att rel_to_avg_rpo_rush_att
## 0 0
## rel_to_avg_times_blitzed rel_to_avg_times_hurried
## 0 0
## rel_to_avg_times_hit rel_to_avg_times_pressured
## 0 0
## rel_to_avg_times_pressured_pct rel_to_avg_on_tgt_throws
## 0 0
## rel_to_avg_on_tgt_pct rel_to_avg_passing_drops
## 0 0
## rel_to_avg_passing_drop_pct rel_to_avg_passing_bad_throws
## 0 0
## rel_to_avg_passing_bad_throw_pct rel_to_avg_batted_balls
## 0 0
## rel_to_avg_throwaways rel_to_avg_spikes
## 0 0
## rel_to_avg_pocket_time rel_to_avg_targets
## 0 0
## rel_to_avg_targets_red_zone rel_to_avg_targets_gtg
## 0 0
## rel_to_avg_receptions rel_to_avg_receptions_red_zone
## 0 0
## rel_to_avg_receptions_gtg rel_to_avg_receiving_yards
## 0 0
## rel_to_avg_receiving_air_yards rel_to_avg_receiving_air_yards_red_zone
## 0 0
## rel_to_avg_receiving_air_yards_gtg rel_to_avg_yards_after_catch
## 0 0
## rel_to_avg_yards_after_contact_rec rel_to_avg_ybc_r
## 0 0
## rel_to_avg_yptarget rel_to_avg_ypr
## 0 0
## rel_to_avg_rec_adot rel_to_avg_receiving_touchdown
## 0 0
## rel_to_avg_receiving_touchdown_red_zone rel_to_avg_receiving_touchdown_gtg
## 0 0
## rel_to_avg_rec_td_pct rel_to_avg_receiving_drop
## 0 0
## rel_to_avg_receiving_drop_pct rel_to_avg_receiving_broken_tackles
## 0 0
## rel_to_avg_receiving_int rel_to_avg_receiving_rat
## 0 0
## rel_to_avg_rush_attempts rel_to_avg_rush_attempts_red_zone
## 0 0
## rel_to_avg_rush_attempts_gtg rel_to_avg_rushing_yards
## 0 0
## rel_to_avg_ypc rel_to_avg_ybc_att
## 0 0
## rel_to_avg_yards_after_contact_att rel_to_avg_rush_touchdown
## 0 0
## rel_to_avg_rush_touchdown_red_zone rel_to_avg_rush_touchdown_gtg
## 0 0
## rel_to_avg_rush_td_pct rel_to_avg_first_down_rush
## 0 0
## rel_to_avg_rushing_broken_tackles_att rel_to_avg_offense_snaps
## 0 0
## rel_to_avg_team_offense_snaps rel_to_avg_offense_pct
## 0 0
## rel_to_avg_third_down_converted rel_to_avg_third_down_failed
## 0 0
## rel_to_avg_fourth_down_converted rel_to_avg_fourth_down_failed
## 0 0
## rel_to_avg_safety rel_to_avg_tackled_for_loss
## 0 0
## rel_to_avg_broken_tackles rel_to_avg_touches
## 0 0
## rel_to_avg_total_yards rel_to_avg_total_tds
## 0 0
## rel_to_avg_td_pct rel_to_avg_yptouch
## 0 0
## rel_to_avg_ybc rel_to_avg_yards_after_contact
## 0 0
## rel_to_avg_x1d rel_to_avg_fantasy_points_standard
## 0 0
## rel_to_avg_fantasy_points_half_ppr rel_to_avg_fantasy_points_ppr
## 0 0
## z_score_shotgun z_score_no_huddle
## 0 0
## z_score_qb_dropback z_score_qb_scramble
## 0 0
## z_score_scrambles z_score_pass_attempts
## 0 0
## z_score_pass_attempts_red_zone z_score_pass_attempts_gtg
## 0 0
## z_score_complete_pass z_score_complete_pass_red_zone
## 0 0
## z_score_complete_pass_gtg z_score_incomplete_pass
## 0 0
## z_score_passing_yards z_score_passing_air_yards
## 0 0
## z_score_comp_pct z_score_ypa
## 0 0
## z_score_ayptarget z_score_pass_adot
## 0 0
## z_score_passer_rating z_score_pass_touchdown
## 0 0
## z_score_pass_touchdown_red_zone z_score_pass_touchdown_gtg
## 0 0
## z_score_pass_td_pct z_score_interception
## 0 0
## z_score_int_pct z_score_first_down_pass
## 0 0
## z_score_pa_pass_att z_score_rpo_plays
## 0 0
## z_score_rpo_pass_att z_score_rpo_rush_att
## 0 0
## z_score_times_blitzed z_score_times_hurried
## 0 0
## z_score_times_hit z_score_times_pressured
## 0 0
## z_score_times_pressured_pct z_score_on_tgt_throws
## 0 0
## z_score_on_tgt_pct z_score_passing_drops
## 0 0
## z_score_passing_drop_pct z_score_passing_bad_throws
## 0 0
## z_score_passing_bad_throw_pct z_score_batted_balls
## 0 0
## z_score_throwaways z_score_spikes
## 0 0
## z_score_pocket_time z_score_targets
## 0 0
## z_score_targets_red_zone z_score_targets_gtg
## 0 0
## z_score_receptions z_score_receptions_red_zone
## 0 0
## z_score_receptions_gtg z_score_receiving_yards
## 0 0
## z_score_receiving_air_yards z_score_receiving_air_yards_red_zone
## 0 0
## z_score_receiving_air_yards_gtg z_score_yards_after_catch
## 0 0
## z_score_yards_after_contact_rec z_score_ybc_r
## 0 0
## z_score_yptarget z_score_ypr
## 0 0
## z_score_rec_adot z_score_receiving_touchdown
## 0 0
## z_score_receiving_touchdown_red_zone z_score_receiving_touchdown_gtg
## 0 0
## z_score_rec_td_pct z_score_receiving_drop
## 0 0
## z_score_receiving_drop_pct z_score_receiving_broken_tackles
## 0 0
## z_score_receiving_int z_score_receiving_rat
## 0 0
## z_score_rush_attempts z_score_rush_attempts_red_zone
## 0 0
## z_score_rush_attempts_gtg z_score_rushing_yards
## 0 0
## z_score_ypc z_score_ybc_att
## 0 0
## z_score_yards_after_contact_att z_score_rush_touchdown
## 0 0
## z_score_rush_touchdown_red_zone z_score_rush_touchdown_gtg
## 0 0
## z_score_rush_td_pct z_score_first_down_rush
## 0 0
## z_score_rushing_broken_tackles_att z_score_offense_snaps
## 0 0
## z_score_team_offense_snaps z_score_offense_pct
## 0 0
## z_score_third_down_converted z_score_third_down_failed
## 0 0
## z_score_fourth_down_converted z_score_fourth_down_failed
## 0 0
## z_score_safety z_score_tackled_for_loss
## 0 0
## z_score_broken_tackles z_score_touches
## 0 0
## z_score_total_yards z_score_total_tds
## 0 0
## z_score_td_pct z_score_yptouch
## 0 0
## z_score_ybc z_score_yards_after_contact
## 0 0
## z_score_x1d z_score_fantasy_points_standard
## 0 0
## z_score_fantasy_points_half_ppr z_score_fantasy_points_ppr
## 0 0
## cum_shotgun cum_no_huddle
## 0 0
## cum_qb_dropback cum_qb_scramble
## 0 0
## cum_pass_attempts cum_pass_attempts_red_zone
## 0 0
## cum_pass_attempts_gtg cum_complete_pass
## 0 0
## cum_complete_pass_red_zone cum_complete_pass_gtg
## 0 0
## cum_incomplete_pass cum_passing_yards
## 0 0
## cum_passing_air_yards cum_pass_touchdown
## 0 0
## cum_pass_touchdown_red_zone cum_pass_touchdown_gtg
## 0 0
## cum_interception cum_first_down_pass
## 0 0
## cum_targets cum_targets_red_zone
## 0 0
## cum_targets_gtg cum_receptions
## 0 0
## cum_receptions_red_zone cum_receptions_gtg
## 0 0
## cum_receiving_yards cum_receiving_air_yards
## 0 0
## cum_receiving_air_yards_red_zone cum_receiving_air_yards_gtg
## 0 0
## cum_yards_after_catch cum_receiving_touchdown
## 0 0
## cum_receiving_touchdown_red_zone cum_receiving_touchdown_gtg
## 0 0
## cum_rush_attempts cum_rush_attempts_red_zone
## 0 0
## cum_rush_attempts_gtg cum_rushing_yards
## 0 0
## cum_rush_touchdown cum_rush_touchdown_red_zone
## 0 0
## cum_rush_touchdown_gtg cum_first_down_rush
## 0 0
## cum_third_down_converted cum_third_down_failed
## 0 0
## cum_fourth_down_converted cum_fourth_down_failed
## 0 0
## cum_safety cum_tackled_for_loss
## 0 0
## cum_fantasy_points_standard cum_fantasy_points_half_ppr
## 0 0
## cum_fantasy_points_ppr
## 0
# load tidyverse.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#Creating a regular season data frame
NFL_Data_RS <- subset(NFL_Data, season_type == "REG",
select = c(player_id, player_name, position, team, season, season_type, rush_attempts, rushing_yards, rush_touchdown))
# Checking structure of updated data frame.
str(NFL_Data_RS)
## 'data.frame': 8908 obs. of 9 variables:
## $ player_id : chr "00-0038389" "00-0031021" "00-0031021" "00-0031021" ...
## $ player_name : chr "Israel Abanikanda" "Jared Abbrederis" "Jared Abbrederis" "Jared Abbrederis" ...
## $ position : chr "RB" "WR" "WR" "WR" ...
## $ team : chr "NYJ" "DET" "GB" "GB" ...
## $ season : int 2023 2017 2015 2016 2014 2015 2021 2015 2016 2017 ...
## $ season_type : chr "REG" "REG" "REG" "REG" ...
## $ rush_attempts : int 22 0 0 0 0 2 47 155 18 174 ...
## $ rushing_yards : int 70 0 0 0 0 34 130 585 101 573 ...
## $ rush_touchdown: int 0 0 0 0 0 0 0 2 0 7 ...
NFL_Multiple_Records <- NFL_Data_RS %>% # Passing NFL_DATA_RS to next function. Creating multiple records data frame.
group_by(player_id, season) %>% # Grouping players by player id and season.
summarize(Record_Count = n()) %>% # Counting records within each group
filter(Record_Count > 1) #Retaining groups with multiple records.
## `summarise()` has regrouped the output.
## ℹ Summaries were computed grouped by player_id and season.
## ℹ Output is grouped by player_id.
## ℹ Use `summarise(.groups = "drop_last")` to silence this message.
## ℹ Use `summarise(.by = c(player_id, season))` for per-operation grouping
## (`?dplyr::dplyr_by`) instead.
# Viewing multiple records data frame.
view(NFL_Multiple_Records)
# Checking multiple records data frame structure.
str((NFL_Multiple_Records))
## gropd_df [215 × 3] (S3: grouped_df/tbl_df/tbl/data.frame)
## $ player_id : chr [1:215] "00-0022984" "00-0023437" "00-0023438" "00-0023968" ...
## $ season : int [1:215] 2012 2014 2012 2012 2015 2014 2015 2017 2021 2012 ...
## $ Record_Count: int [1:215] 2 2 2 2 2 2 2 2 2 2 ...
## - attr(*, "groups")= tibble [196 × 2] (S3: tbl_df/tbl/data.frame)
## ..$ player_id: chr [1:196] "00-0022984" "00-0023437" "00-0023438" "00-0023968" ...
## ..$ .rows : list<int> [1:196]
## .. ..$ : int 1
## .. ..$ : int 2
## .. ..$ : int 3
## .. ..$ : int 4
## .. ..$ : int 5
## .. ..$ : int 6
## .. ..$ : int 7
## .. ..$ : int [1:2] 8 9
## .. ..$ : int 10
## .. ..$ : int 11
## .. ..$ : int 12
## .. ..$ : int 13
## .. ..$ : int 14
## .. ..$ : int 15
## .. ..$ : int 16
## .. ..$ : int 17
## .. ..$ : int 18
## .. ..$ : int 19
## .. ..$ : int 20
## .. ..$ : int 21
## .. ..$ : int 22
## .. ..$ : int 23
## .. ..$ : int 24
## .. ..$ : int 25
## .. ..$ : int 26
## .. ..$ : int 27
## .. ..$ : int 28
## .. ..$ : int 29
## .. ..$ : int 30
## .. ..$ : int 31
## .. ..$ : int 32
## .. ..$ : int 33
## .. ..$ : int 34
## .. ..$ : int 35
## .. ..$ : int 36
## .. ..$ : int 37
## .. ..$ : int 38
## .. ..$ : int 39
## .. ..$ : int 40
## .. ..$ : int 41
## .. ..$ : int 42
## .. ..$ : int 43
## .. ..$ : int 44
## .. ..$ : int 45
## .. ..$ : int 46
## .. ..$ : int 47
## .. ..$ : int 48
## .. ..$ : int 49
## .. ..$ : int 50
## .. ..$ : int 51
## .. ..$ : int 52
## .. ..$ : int [1:2] 53 54
## .. ..$ : int 55
## .. ..$ : int 56
## .. ..$ : int 57
## .. ..$ : int 58
## .. ..$ : int 59
## .. ..$ : int 60
## .. ..$ : int 61
## .. ..$ : int [1:2] 62 63
## .. ..$ : int 64
## .. ..$ : int 65
## .. ..$ : int 66
## .. ..$ : int [1:2] 67 68
## .. ..$ : int 69
## .. ..$ : int 70
## .. ..$ : int 71
## .. ..$ : int [1:2] 72 73
## .. ..$ : int 74
## .. ..$ : int [1:2] 75 76
## .. ..$ : int 77
## .. ..$ : int 78
## .. ..$ : int 79
## .. ..$ : int 80
## .. ..$ : int 81
## .. ..$ : int 82
## .. ..$ : int 83
## .. ..$ : int 84
## .. ..$ : int 85
## .. ..$ : int 86
## .. ..$ : int 87
## .. ..$ : int 88
## .. ..$ : int 89
## .. ..$ : int [1:2] 90 91
## .. ..$ : int 92
## .. ..$ : int [1:2] 93 94
## .. ..$ : int 95
## .. ..$ : int 96
## .. ..$ : int 97
## .. ..$ : int 98
## .. ..$ : int 99
## .. ..$ : int 100
## .. ..$ : int 101
## .. ..$ : int 102
## .. ..$ : int 103
## .. ..$ : int 104
## .. ..$ : int 105
## .. ..$ : int 106
## .. ..$ : int 107
## .. .. [list output truncated]
## .. ..@ ptype: int(0)
## ..- attr(*, ".drop")= logi TRUE
subset(NFL_Data_RS, player_id == "00-0022984" & season == 2012)
## player_id player_name position team season season_type rush_attempts
## 3679 00-0022984 Ryan Grant RB GB 2012 REG 34
## 3680 00-0022984 Ryan Grant RB WAS 2012 REG 1
## rushing_yards rush_touchdown
## 3679 169 2
## 3680 5 0
NFL_Data_RS <- NFL_Data_RS %>% #Passing NFL_Data_RS to next function.
#Also, combining rushing yards, attempts, and touchdowns so they're a combined record for any players with multiple records.
group_by(player_id, player_name, position, season) %>% # Creating a group by player id, name, position for each season.
summarise(rushing_yards = sum(rushing_yards),
rush_attempts = sum(rush_attempts),
rush_touchdown = sum(rush_touchdown))
## `summarise()` has regrouped the output.
## ℹ Summaries were computed grouped by player_id, player_name, position, and
## season.
## ℹ Output is grouped by player_id, player_name, and position.
## ℹ Use `summarise(.groups = "drop_last")` to silence this message.
## ℹ Use `summarise(.by = c(player_id, player_name, position, season))` for
## per-operation grouping (`?dplyr::dplyr_by`) instead.
# Checking structure of updated NFL_Data_RS data frame.
str(NFL_Data_RS)
## gropd_df [8,687 × 7] (S3: grouped_df/tbl_df/tbl/data.frame)
## $ player_id : chr [1:8687] "00-0000865" "00-0004541" "00-0006101" "00-0006101" ...
## $ player_name : chr [1:8687] "Charlie Batch" "Donald Driver" "Tony Gonzalez" "Tony Gonzalez" ...
## $ position : chr [1:8687] "QB" "WR" "TE" "TE" ...
## $ season : int [1:8687] 2012 2012 2012 2013 2012 2013 2014 2015 2012 2013 ...
## $ rushing_yards : int [1:8687] 0 0 0 0 38 -2 -11 15 6 -31 ...
## $ rush_attempts : int [1:8687] 0 0 0 0 16 2 8 16 23 47 ...
## $ rush_touchdown: int [1:8687] 0 0 0 0 0 0 0 0 0 1 ...
## - attr(*, "groups")= tibble [2,684 × 4] (S3: tbl_df/tbl/data.frame)
## ..$ player_id : chr [1:2684] "00-0000865" "00-0004541" "00-0006101" "00-0007091" ...
## ..$ player_name: chr [1:2684] "Charlie Batch" "Donald Driver" "Tony Gonzalez" "Matt Hasselbeck" ...
## ..$ position : chr [1:2684] "QB" "WR" "TE" "QB" ...
## ..$ .rows : list<int> [1:2684]
## .. ..$ : int 1
## .. ..$ : int 2
## .. ..$ : int [1:2] 3 4
## .. ..$ : int [1:4] 5 6 7 8
## .. ..$ : int [1:4] 9 10 11 12
## .. ..$ : int 13
## .. ..$ : int [1:2] 14 15
## .. ..$ : int 16
## .. ..$ : int 17
## .. ..$ : int 18
## .. ..$ : int [1:11] 19 20 21 22 23 24 25 26 27 28 ...
## .. ..$ : int 30
## .. ..$ : int [1:2] 31 32
## .. ..$ : int 33
## .. ..$ : int [1:4] 34 35 36 37
## .. ..$ : int 38
## .. ..$ : int [1:5] 39 40 41 42 43
## .. ..$ : int 44
## .. ..$ : int 45
## .. ..$ : int [1:3] 46 47 48
## .. ..$ : int [1:3] 49 50 51
## .. ..$ : int 52
## .. ..$ : int [1:9] 53 54 55 56 57 58 59 60 61
## .. ..$ : int 62
## .. ..$ : int [1:5] 63 64 65 66 67
## .. ..$ : int 68
## .. ..$ : int 69
## .. ..$ : int 70
## .. ..$ : int 71
## .. ..$ : int 72
## .. ..$ : int 73
## .. ..$ : int [1:7] 74 75 76 77 78 79 80
## .. ..$ : int 81
## .. ..$ : int 82
## .. ..$ : int [1:6] 83 84 85 86 87 88
## .. ..$ : int 89
## .. ..$ : int [1:7] 90 91 92 93 94 95 96
## .. ..$ : int [1:2] 97 98
## .. ..$ : int [1:5] 99 100 101 102 103
## .. ..$ : int 104
## .. ..$ : int 105
## .. ..$ : int 106
## .. ..$ : int [1:2] 107 108
## .. ..$ : int 109
## .. ..$ : int [1:5] 110 111 112 113 114
## .. ..$ : int [1:2] 115 116
## .. ..$ : int 117
## .. ..$ : int [1:5] 118 119 120 121 122
## .. ..$ : int [1:2] 123 124
## .. ..$ : int [1:8] 125 126 127 128 129 130 131 132
## .. ..$ : int [1:2] 133 134
## .. ..$ : int 135
## .. ..$ : int [1:2] 136 137
## .. ..$ : int 138
## .. ..$ : int 139
## .. ..$ : int 140
## .. ..$ : int [1:2] 141 142
## .. ..$ : int 143
## .. ..$ : int 144
## .. ..$ : int [1:4] 145 146 147 148
## .. ..$ : int 149
## .. ..$ : int [1:4] 150 151 152 153
## .. ..$ : int 154
## .. ..$ : int [1:4] 155 156 157 158
## .. ..$ : int 159
## .. ..$ : int 160
## .. ..$ : int 161
## .. ..$ : int 162
## .. ..$ : int [1:8] 163 164 165 166 167 168 169 170
## .. ..$ : int [1:8] 171 172 173 174 175 176 177 178
## .. ..$ : int [1:4] 179 180 181 182
## .. ..$ : int 183
## .. ..$ : int [1:5] 184 185 186 187 188
## .. ..$ : int [1:2] 189 190
## .. ..$ : int 191
## .. ..$ : int [1:3] 192 193 194
## .. ..$ : int [1:2] 195 196
## .. ..$ : int 197
## .. ..$ : int [1:9] 198 199 200 201 202 203 204 205 206
## .. ..$ : int [1:2] 207 208
## .. ..$ : int [1:10] 209 210 211 212 213 214 215 216 217 218
## .. ..$ : int 219
## .. ..$ : int [1:10] 220 221 222 223 224 225 226 227 228 229
## .. ..$ : int [1:7] 230 231 232 233 234 235 236
## .. ..$ : int 237
## .. ..$ : int [1:6] 238 239 240 241 242 243
## .. ..$ : int [1:2] 244 245
## .. ..$ : int [1:3] 246 247 248
## .. ..$ : int 249
## .. ..$ : int 250
## .. ..$ : int 251
## .. ..$ : int [1:4] 252 253 254 255
## .. ..$ : int 256
## .. ..$ : int [1:4] 257 258 259 260
## .. ..$ : int 261
## .. ..$ : int [1:8] 262 263 264 265 266 267 268 269
## .. ..$ : int [1:3] 270 271 272
## .. ..$ : int 273
## .. ..$ : int 274
## .. .. [list output truncated]
## .. ..@ ptype: int(0)
## ..- attr(*, ".drop")= logi TRUE
NFL_Multiple_Records2 <- NFL_Data_RS %>% # Passing NFL_DATA_RS to next function.
group_by(player_id, season) %>% # Grouping players by player id and season.
summarize(Record_Count = n()) %>% # Counting records within each group
filter(Record_Count > 1) #Retaining groups with multiple records.
## `summarise()` has regrouped the output.
## ℹ Summaries were computed grouped by player_id and season.
## ℹ Output is grouped by player_id.
## ℹ Use `summarise(.groups = "drop_last")` to silence this message.
## ℹ Use `summarise(.by = c(player_id, season))` for per-operation grouping
## (`?dplyr::dplyr_by`) instead.
# Viewing updated data frame.
view(NFL_Multiple_Records2)
# Checking structure of NFL multiple records 2 data frame.
str((NFL_Multiple_Records2))
## gropd_df [0 × 3] (S3: grouped_df/tbl_df/tbl/data.frame)
## $ player_id : chr(0)
## $ season : int(0)
## $ Record_Count: int(0)
## - attr(*, "groups")= tibble [0 × 2] (S3: tbl_df/tbl/data.frame)
## ..$ player_id: chr(0)
## ..$ .rows : list<int> [1:0]
## list()
## .. ..@ ptype: int(0)
## ..- attr(*, ".drop")= logi TRUE
subset(NFL_Data_RS, player_id == "00-0022984" & season == 2012) # Checking the record for the same player we used to identify multiple records to see if they're combined.
## # A tibble: 1 × 7
## # Groups: player_id, player_name, position [1]
## player_id player_name position season rushing_yards rush_attempts
## <chr> <chr> <chr> <int> <int> <int>
## 1 00-0022984 Ryan Grant RB 2012 174 35
## # ℹ 1 more variable: rush_touchdown <int>
# Ryan Grant's records have been combined as expected for the 2012 season.
summary(NFL_Data_RS$season)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2012 2015 2019 2019 2022 2025
library(plotly) # Adding plotly library.
## Warning: package 'plotly' was built under R version 4.6.2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
NFL_Data_RS %>% # Passing nfl regular season data to filter function
filter(position == "RB" | position == "QB") %>% # Passing filtered data containing just running back and quarterback results to plotly function.
plot_ly(x = ~rushing_yards, y = ~rush_touchdown, # Creating a scatter plot with rushing yards on the x axis and rushing touchdowns on the y axis.
hoverinfo = "text", # Adding hover text for each of the points on the plot.
text = ~paste("Player: ", player_name, # The first line will be the player's name.
"<br> Season:", season, # The second line will be the season.
"<br> Rushing Touchdowns: ", rush_touchdown, # The third line will be how many touchdowns the player had that season.
"<br> Rushing Yards: ", rushing_yards)) %>% # The fourth line will be how many rushing yards the player had that season.
add_markers(showlegend = TRUE, # Showing legend.
color = ~position, # Showing color by position.
colors = c("blue", "red")) %>% #Making the QB position have blue dots and the RB position have red dots.
layout(xaxis = list(title = "Rushing Yards"), # Adding x axis label.
yaxis = list(title = "Rushing Touchdowns"), # Adding y axis label.
title = "NFL Rushing Yards vs Touchdowns (2012 to 2025)") # Adding title.
NFL_Data_RS %>% # Passing nfl regular season data to filter function
filter(position == "RB" | position == "QB") %>% # Passing filtered data containing just running back and quarterback results to plotly function.
plot_ly(x = ~rushing_yards, y = ~rush_touchdown, # Creating a scatter plot with rushing yards on the x axis and rushing touchdowns on the y axis.
hoverinfo = "text", # Adding hover text for each of the points on the plot.
text = ~paste("Player: ", player_name, # The first line will be the player's name.
"<br> Season:", season, # The second line will be the season.
"<br> Rushing Touchdowns: ", rush_touchdown, # The third line will be how many touchdowns the player had that season.
"<br> Rushing Yards: ", rushing_yards)) %>% # The fourth line will be how many rushing yards the player had that season.
add_markers(showlegend = TRUE, # Showing legend.
color = ~position, # Showing color by position.
colors = c("blue", "red"), #Making the QB position have blue dots and the RB position have red dots.
frame = ~season, # Adding frames by season.
ids = ~player_id) %>% # Using unique player ids to track each player by season.
layout(xaxis = list(title = "Rushing Yards"), # Adding x axis label.
yaxis = list(title = "Rushing Touchdowns"), # Adding y axis label.
title = "NFL Rushing Touchdowns vs Rushing Yards (2012 to 2025)") %>% # Adding title.
animation_opts(frame = 3000, # Holding each frame for 3 seconds.
transition = 1000, # Transitioning each frame for 1 second.
easing = "sin") %>% # Smoothing the transition between frames.
animation_slider(currentvalue = list(prefix = NULL, # Adding animation slider current value to make it easier to see which season for each frame.
font = list(color = "black", # Making the text black.
size = 30))) # Making text more pronounced.