Introduction

Column

A Brief History and background Information

Professional Football began in 1920 and comprised of 5 teams. The first Pro Football team was the Dayton Triangles! Over the years, The NFL survived many years of instability, and a rival organization came to the scene in the 1960s. This rival organization, the AFL, merged with the NFL to create a single organization with 26 teams. Since then, 6 new teams have been added to have the 32 teams that are still there today. The NFL is split into 2 conferences, the AFC and NFC. Within each conference, there are 4 divisions with 4 teams in each division. Every team plays the other 3 teams in their division twice. Every team plays 17 games in the regular season.

We are coming to an end of the regular season this year, and soon the playoffs will start. There are 14 teams that make the playoffs, and they expanded it from 12 to 14 before the 2020 season. Every divisional winner makes the playoffs, and there are 3 wildcard teams in each conference that make it.

Why Player Salary vs Wins?

The style of play in the NFL has changed over the years. Offenses used to be running oriented, but now they are more passing oriented than ever. The Runningback position used to be one of the most important positions in the NFL, but today people say it’s one of the most replaceable positions. Another argument that many people talk about is how much a Quarterback should be paid. If a team uses too much of their salary on their Quarterback, they won’t have enough to pay the rest of the team.

Column {data-width = 500}

Goals

The goal of this project is to see if there is a connection between how certain positions are paid and how the team did that year.

Questions this project aims to solve:

  • Do teams that pay their runningback less relate to more wins?

  • Do teams that pay their quarterback more relate to more wins?

  • Do teams that use more of their money on defense relate to more wins, or is it better that teams spend most of their money on offense?

Data Introduction

Column

2022 Payroll and Wins Dataset

Record, Points For, Points Allowed, and Net Points

Conference and Location

Variable Descriptions

Team: Name of football team.

QB through K/P/LS: Salary total of each position.

W: Total amount of wins.

L: Total amount of losses.

T: Total amount of ties.

PCT: Winning percentage.

PF: Total points that the team scored.

PA: Total points that the team allowed.

Net Pts: PF - PA

Conference: Split into 2 conferences, AFC and NFC

Latitude: Latitude of the stadium

Longitude: Longitude of the stadium.

Positional Payroll vs Win PCT

Column

2022 RB Payroll vs Win PCT

2022 QB Payroll vs Win PCT

2022 WR Payroll vs Win PCT

2022 OL Payroll vs Win PCT

2022 Defensive Payroll vs Win PCT

2022 Special Teams Payroll vs Win PCT

NFL Salary vs. Points for and Points Allowed

Column

NFL QB Payroll vs. Points For

2022 Defensive Payroll vs Point Allowed

Conclusion

Column

A Brief History and background Information

Looking back at the goals of the project, there were some surprising findings. Recent talk shows and other media outlets have suggested that paying Runningbacks is something a team shouldn’t due because there is a high chance that they get injured. According to our findings, there is a positive correlation between paying Runningbacks and Team Win Percentage. The strongest correlation that we found was Defensive Payroll vs. Win PCT. Paying your Defense results in more wins, on average, all else equal. Overall, there is a lot more that goes into how teams win games besides Payroll. Coaches, GMs, and many other statistics that weren’t in this data set all play rolls on how teams win games.

Column {data-width = 500}

Limitations

A limitation to this project is that I only used data from the 2022 season. If this data set included more seasons besides last year, it would have been interesting to see how the different data sets match up. Another limitation to this project was that there could have been more statistics used to have an even further analysis. Some of these stats include: Passing TDs, Passing Yds, Rushing TDs, Rushing Yds, Sacks, INTs.

---
title: "NFL Player Salary vs Wins"
output: 
  flexdashboard::flex_dashboard:
    theme:
      version: 4
      bootswatch: simplex
      navbar-bg: "blue"
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

<style>
.chart-title {  /* chart_title  */
   font-size: 16px;
  }
body{ /* Normal  */
      font-size: 14px;
  }
</style>

```{r setup, include=FALSE}
library(flexdashboard)
library(pacman)
library(readxl)
library(ggplot2)
library(ggrepel)

p_load(tidyverse, maps, viridis, ggplot2, plotly, htmltab, readr, leaflet, scales, plyr, reshape2, ggcorrplot, gridExtra)
```

Introduction
===

Column {data-width=500}
-----------------------------------------------------------------------

### A Brief History and background Information

Professional Football began in 1920 and comprised of 5 teams. The first Pro Football team was the Dayton Triangles! Over the years, The NFL survived many years of instability, and a rival organization came to the scene in the 1960s. This rival organization, the AFL, merged with the NFL to create a single organization with 26 teams. Since then, 6 new teams have been added to have the 32 teams that are still there today. The NFL is split into 2 conferences, the AFC and NFC. Within each conference, there are 4 divisions with 4 teams in each division. Every team plays the other 3 teams in their division twice. Every team plays 17 games in the regular season. 

We are coming to an end of the regular season this year, and soon the playoffs will start. There are 14 teams that make the playoffs, and they expanded it from 12 to 14 before the 2020 season. Every divisional winner makes the playoffs, and there are 3 wildcard teams in each conference that make it.  

### Why Player Salary vs Wins?

The style of play in the NFL has changed over the years. Offenses used to be running oriented, but now they are more passing oriented than ever. The Runningback position used to be one of the most important positions in the NFL, but today people say it's one of the most replaceable positions. Another argument that many people talk about is how much a Quarterback should be paid. If a team uses too much of their salary on their Quarterback, they won't have enough to pay the rest of the team.

Column {data-width = 500}
---

### Goals

The goal of this project is to see if there is a connection between how certain positions are paid and how the team did that year.

Questions this project aims to solve:

- Do teams that pay their runningback less relate to more wins?

- Do teams that pay their quarterback more relate to more wins?

- Do teams that use more of their money on defense relate to more wins, or is it better that teams spend most of their money on offense?

Data Introduction
===

Column{.tabset data-width=550}
---

### 2022 Payroll and Wins Dataset

```{r}
NFL2022_ <- read_excel("C:/Users/19377/Downloads/NFL2022!.xlsx")

NFL2022_ <- NFL2022_[ , names(NFL2022_) %in% c("Team", "Players", "QB", "RB/FB", "WR", "TE", "OL", "DL", "LB", "DB", "K/P/LS", "Total", "PCT")]

DT::datatable(NFL2022_, rownames = FALSE, 
              colnames = c("Team", "Players", "QB", "RB/FB", "WR", "TE", "OL", "DL", "LB", "DB", "K/P/LS", "Total", "PCT" ))
```

### Record, Points For, Points Allowed, and Net Points

```{r}
NFL2022_ <- read_excel("C:/Users/19377/Downloads/NFL2022!.xlsx")

NFL2022_ <- NFL2022_[ , names(NFL2022_) %in% c("Team", "W", "L", "T", "PCT", "PF", "PA", "Net Pts")]

DT::datatable(NFL2022_, rownames = FALSE, 
              colnames = c("Team", "W", "L", "T", "PCT", "PF", "PA", "Net Pts"))
```

### Conference and Location

```{r}
NFL2022_ <- read_excel("C:/Users/19377/Downloads/NFL2022!.xlsx")

NFL2022_ <- NFL2022_[ , names(NFL2022_) %in% c("Team", "Conference", "latitude", "longitude")]

DT::datatable(NFL2022_, rownames = FALSE, 
              colnames = c("Team", "Conference", "latitude", "longitude"))

```

### Variable Descriptions

Team: Name of football team.

QB through K/P/LS: Salary total of each position.

W: Total amount of wins.

L: Total amount of losses.

T: Total amount of ties.

PCT: Winning percentage.

PF: Total points that the team scored.

PA: Total points that the team allowed.

Net Pts: PF - PA

Conference: Split into 2 conferences, AFC and NFC

Latitude: Latitude of the stadium

Longitude: Longitude of the stadium. 

Positional Payroll vs Win PCT
===

Column{.tabset data-width=550}
---

### 2022 RB Payroll vs Win PCT

```{r inputs}
NFL2022_ <- read_excel("C:/Users/19377/Downloads/NFL2022!.xlsx")
```

```{r scatter of RB vs Win PCT}
NFL2022_$RB_PCT <- (NFL2022_$`RB/FB` / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = RB_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.05) +
  labs(title = "RB Payroll vs. Win Percentage",
    x = "Runningback Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```

### 2022 QB Payroll vs Win PCT

```{r scatter of QB vs Win PCT}
NFL2022_$QB_PCT <- (NFL2022_$QB / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = QB_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "QB Payroll vs. Win Percentage",
    x = "Quarterback Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```

### 2022 WR Payroll vs Win PCT

```{r scatter of WR vs Win PCT}
NFL2022_$WR_PCT <- (NFL2022_$WR / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = WR_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "Wide Receiver Payroll vs. Win Percentage",
    x = "Wide Receiver Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```


### 2022 OL Payroll vs Win PCT

```{r scatter of OL vs Win PCT}
NFL2022_$OL_PCT <- (NFL2022_$OL / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = OL_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "OL Payroll vs. Win Percentage",
    x = "Offensive Line Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```

### 2022 Defensive Payroll vs Win PCT

```{r scatter of DF vs Win PCT}
NFL2022_$DF_PCT <- (NFL2022_$DL + NFL2022_$LB + NFL2022_$DB / NFL2022_$Total) / 100000000

ggplot(NFL2022_, aes(x = DF_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "Defensive Payroll vs. Win Percentage",
    x = "Defensive Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```

### 2022 Special Teams Payroll vs Win PCT

```{r scatter of SP vs Win PCT}
NFL2022_$SP_PCT <- (NFL2022_$`K/P/LS` / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = SP_PCT, y = PCT)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.05) +
  labs(title = "K/P/LS Payroll vs. Win Percentage",
    x = "Special Teams Payroll Percentage",
    y = "Win Percentage") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```


NFL Salary vs. Points for and Points Allowed
===

Column{.tabset data-width=550}
---

### NFL QB Payroll vs. Points For

```{r inputs2}
NFL2022_ <- read_excel("C:/Users/19377/Downloads/NFL2022!.xlsx")
```

```{r scatter of QB vs PF}
NFL2022_$QB_PCT <- (NFL2022_$QB / NFL2022_$Total) 

ggplot(NFL2022_, aes(x = QB_PCT, y = PF)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "QB Payroll vs. Point For",
    x = "Quarterback Payroll Percentage",
    y = "Points For") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```


### 2022 Defensive Payroll vs Point Allowed

```{r scatter of DF vs Points Allowed}
NFL2022_$DF_PCT <- (NFL2022_$DL + NFL2022_$LB + NFL2022_$DB / NFL2022_$Total) / 100000000

ggplot(NFL2022_, aes(x = DF_PCT, y = PA)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE, col = "red") +
  geom_text_repel(aes(label = Team), nudge_y = 0.035) +
  labs(title = "Defensive Payroll vs. Points Allowed",
    x = "Defensive Payroll Percentage",
    y = "Points Allowed") + 
  scale_x_continuous(labels = scales::percent_format()) + 
  theme_minimal() 
```

Conclusion
===

Column {data-width=500}
-----------------------------------------------------------------------

### A Brief History and background Information

Looking back at the goals of the project, there were some surprising findings. Recent talk shows and other media outlets have suggested that paying Runningbacks is something a team shouldn't due because there is a high chance that they get injured. According to our findings, there is a positive correlation between paying Runningbacks and Team Win Percentage. The strongest correlation that we found was Defensive Payroll vs. Win PCT. Paying your Defense results in more wins, on average, all else equal. Overall, there is a lot more that goes into how teams win games besides Payroll. Coaches, GMs, and many other statistics that weren't in this data set all play rolls on how teams win games. 


Column {data-width = 500}
---

### Limitations

A limitation to this project is that I only used data from the 2022 season. If this data set included more seasons besides last year, it would have been interesting to see how the different data sets match up. Another limitation to this project was that there could have been more statistics used to have an even further analysis. Some of these stats include: Passing TDs, Passing Yds, Rushing TDs, Rushing Yds, Sacks, INTs.