We do not know current trends to indicate attendance
rates throughout the years of NFL Games. If these
attendance rates are increasing, that could be
a problem for the future since we may not have enough seats to fit
everyone. If the amount of people attending decreases, then we
may have to allocate our funds to more online viewers. Seats are not the
only problem, since larger in person attendance rates
call for both an increase in security as well as an increase in
concessions production.
This evaluation will show either an increase or
decrease of in person
attendance. From this information, we can be more
informed on our future choices related to the
National Football League. We will also look at winner
trends and how they may affect the attendance of games.
If the amount of people attending these events are increasing, then we can advertise how limited these tickets are, and increase prices so that less people would buy them, which allows us to fit more people into these games. Although, if the amount of people attending are decreasing, then as said before, we may have to focus less on in-person maintenance and more on online viewing options and advertisements. Also as mentioned before, once we know attendance tends, we can then plan the amount of security and concessions required for the predicted amount of people.
library(tidyverse)
library(knitr)
library(tidyr)
library(modelr)
The package we have loaded in order to work with the data set is
tidyverse. This package provides many functions that help
with altering, rearranging, and viewing data.
The knitr package will allow us to display tables more
nicely and the tidyr package will help provide more data
altering functions. modelr will allow us to add
trendlines to graphs.
In the original attendance.csv data file, there are 8
variables.
team - Which state each team represents.
team-name - The name the team chose for themselves,
like Cardinals or Falcons.
year - The year in which the game week
occurred.
total - The total amount of people that attended
that year.
home - The amount of viewers attending that support
the home team.
away - The amount of viewers attending that support
the away team.
week - A number range from 1-17 that displays which
week the game happened.
weekly_attendance - The number of viewers attending
that week.
First, we must upload our data from our files. We set the working
directory in order to find the file, and then assign the file to the
DataFrame named attendance.
setwd("C:/Users/taing/OneDrive/Documents/Math items/B Bus 301 A Au 23/Week_10/nfl")
attendance <- read.csv("attendance.csv")
games <- read.csv("games.csv")
Now we need to combine both csv files.
games$week <- as.numeric(games$week)
## Warning: NAs introduced by coercion
attendance <- attendance %>%
unite("home_team", team, team_name, sep = " ") %>%
full_join(games, c("home_team" = "home_team", "year" = "year", "week" = "week"))
After getting our two csv files together, we need to fix it to only
focus on what we’re interested in, which is team,
year and total attendance. So, we use the
transmute function to other gather certain variables from
the original data frame. Our new variable will be att_fix,
being short for the fixed attendance data frame.
att_fix <- transmute(attendance,
home_team = home_team,
year = year,
week = week,
total = total,
winner = (winner == home_team))
kable(head(att_fix, 10))
| home_team | year | week | total | winner |
|---|---|---|---|---|
| Arizona Cardinals | 2000 | 1 | 893926 | NA |
| Arizona Cardinals | 2000 | 2 | 893926 | TRUE |
| Arizona Cardinals | 2000 | 3 | 893926 | NA |
| Arizona Cardinals | 2000 | 4 | 893926 | FALSE |
| Arizona Cardinals | 2000 | 5 | 893926 | NA |
| Arizona Cardinals | 2000 | 6 | 893926 | TRUE |
| Arizona Cardinals | 2000 | 7 | 893926 | FALSE |
| Arizona Cardinals | 2000 | 8 | 893926 | NA |
| Arizona Cardinals | 2000 | 9 | 893926 | FALSE |
| Arizona Cardinals | 2000 | 10 | 893926 | TRUE |
For our focus, we will be looking at home_team,
year, week, total, and
winner.
These are all the 34 listed teams that participate in the
NFL games.
unique(att_fix$home_team)
## [1] "Arizona Cardinals" "Atlanta Falcons" "Baltimore Ravens"
## [4] "Buffalo Bills" "Carolina Panthers" "Chicago Bears"
## [7] "Cincinnati Bengals" "Cleveland Browns" "Dallas Cowboys"
## [10] "Denver Broncos" "Detroit Lions" "Green Bay Packers"
## [13] "Indianapolis Colts" "Jacksonville Jaguars" "Kansas City Chiefs"
## [16] "Miami Dolphins" "Minnesota Vikings" "New England Patriots"
## [19] "New Orleans Saints" "New York Giants" "New York Jets"
## [22] "Oakland Raiders" "Philadelphia Eagles" "Pittsburgh Steelers"
## [25] "San Diego Chargers" "San Francisco 49ers" "Seattle Seahawks"
## [28] "St. Louis Rams" "Tampa Bay Buccaneers" "Tennessee Titans"
## [31] "Washington Redskins" "Houston Texans" "Los Angeles Rams"
## [34] "Los Angeles Chargers"
These are the range of years that the data takes place in. As you can see, it is from 2000 to 2019.
summary(att_fix$year)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2000 2005 2010 2010 2015 2019
These are the statistics for the total amount of attendance for each
year of each team. The minimum is shown to be 760,644, the maximum is
1,322,087, and on average, 1,080,910 people attend an NFL
team game per year.
summary(att_fix$total)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 760644 1040509 1081090 1080910 1123230 1322087 220
As shown by the summary, teams play up to 17 weeks in a year. Although the other values we do not care too much of.
summary(att_fix$week)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 1 5 9 9 13 17 220
As shown by this summary, the home team has a more chance of winning compared to losing.
summary(att_fix$winner)
## Mode FALSE TRUE NA's
## logical 2276 3048 5742
One way to look at the data to answer our question would be to look
at each home_team & year as a separate
data point. Although, this might be too much data to work with, so we
may have to instead choose the first few teams or a random sample to
work with. If we want to work with very small amount of data points, we
can look at each team’s attendance throughout their
years to see if it increased or decreased.
If we want to work with large amounts of data points, then we would have to use the scatter plot. If we want to split the data into very small amount of points, then we can use a barplot or histogram.
att_fix %>%
ggplot(aes(year, total)) +
geom_point() +
geom_smooth(se = FALSE, color = "red")
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
## Warning: Removed 220 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 220 rows containing missing values (`geom_point()`).
att_fix %>%
add_predictions(lm(total ~ winner, data = att_fix)) %>%
ggplot(aes(winner, total)) +
geom_point() +
geom_point(aes(y = pred), color = "red", size = 4)
## Warning: Removed 220 rows containing missing values (`geom_point()`).
## Warning: Removed 5742 rows containing missing values (`geom_point()`).
Currently we don’t know how to select either only the first
home_team to observe, or how to collect a sample of our
home_teams. After learning how to do this, the plots and
diagrams will be much more clean, since there will be fewer points.
I have included linear regression in my graphs. The red line or dot shows the average amount of total attendance during the year or whether the team won or not.
As stated at the start of this evaluation, the problem is that we did
not know the trends of attendance rates given the year or success
rate of teams. Knowing this, the NFL
company will prepare the amount of security,
concessions, and advertising depending on the
predicted amount of attendants.
Using two csv files, we gathered general information of
NFL teams such as attendance and statistics about the games
themselves. Using this data, we refined it to only focus on the data we
needed, which was the years, the home_team,
the total amount of people that attended, and the
winnings of the team.
The first scatter plot that was created shows the
correlation between the years and the
total amount of people. As shown on the scatter plot, the
amount of people fluctuate throughout the years. On multiples of 10, the
attendance reaches a low point, where as on multiples of 5 not
being 10, the attendance reaches a high point. Although this
isn’t true for 2000, where it’s a low point instead of a high point.
This could be because they were just starting to count attendance and
hadn’t fully developed the method to do so.
The second scatter plot displays the points at which
the games that are won and lost are displayed. The NA
column are games that are either tied or games that couldn’t be
completed. The two red dots display the averages in each column. It’s a
little difficult to see, but the games in which the
home_team wins have an average attendance slightly
higher than those that don’t win.
The NFL company will be changing many aspects of the
in-person games depending on attendance trends. For years with
less attendance, the company may give more deals in order to
bring more people in, so people may need to pay less for tickets. The
stadium may also be more open, but there may also be less
concessions and security. The opposite is true for
years with increased attendance. This would lead to increase
price to entice less people to attend, but also an increase in
security and concessions.
We may be able to predict that years of 5 have less attendance and years of 10 have more, but that’s only the average. There could be an unexpected factor that changes attendance drastically. Also, because of the drastic range of thousands of attenders per day, the company will most likely only be able to over-prepare or under-prepare. Both outcomes will result in a loss of profit for the company. Too much concessions lead to wasted products the company spent money on. But too little concessions means a loss of potential sales.