This is NBA attendance data for the 2013-2014 season. I picked the 2013-2014 season because it is the last year the Spurs won the Championship, and also to get an idea how league attendance has changed in the last five years. In observation of the map, you may notice that some teams have a home capacity percentage higher than 100. This is due to the fact that teams sell standing-room-only tickets, such as the HEB Fan Zone in the AT&T Center. The result is that the total number of fans attending exceeds the number of seats in the arena.
The original dataset was compiled by Gabe Salazar at data.world. The original dataset is an xlsx file that contains NBA attendance data from 2000-2015. I created a separate xlsx file with just the data from the 2013-2014 season and added the longitude and latitude coordinates of all 29 arenas. There are 30 teams, but the Lakers and Clippers share the Staples Center. Because of this, I adjusted the coordinates for the Clippers slightly in order to distinguish the two on the map as you zoom in.
library(tidyverse)
library(leaflet)
NBA <- read_csv("/Users/ohb544/Desktop/NBA_Attendance14.csv")
Here is the structure of the dataset:
str(NBA)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 30 obs. of 14 variables:
## $ Starting Year : num 2014 2014 2014 2014 2014 ...
## $ Rank : num 30 27 1 2 16 9 18 17 6 19 ...
## $ Team : chr "76ers" "Bucks" "Bulls" "Cavaliers" ...
## $ Home: Total Games : num 41 41 41 41 41 41 41 41 41 41 ...
## $ Home: Total Attendance: num 571572 611226 875091 843042 721350 ...
## $ Home: Avg Attendance : num 13940 14907 21343 20562 17593 ...
## $ Home: % Capactiy : num 68.6 79.6 102 100 94.5 ...
## $ Away: Total Games : num 41 41 41 41 41 41 41 41 41 41 ...
## $ Away: Total Attendance: num 17665 17180 18404 18915 17741 ...
## $ Away: Avg Attendance : num 91.8 88.8 95.7 98.3 91.9 94.7 94.4 90.8 92 91.1 ...
## $ Away: % Capactiy : num 82 82 82 82 82 82 82 82 82 82 ...
## $ Arena : chr "Wells Fargo Center" "Bradley Center" "United Center" "Rocket Mortgage Fieldhouse" ...
## $ Latitude : num 39.9 43 41.9 41.5 42.4 ...
## $ Longitude : num -75.2 -87.9 -87.7 -81.7 -71.1 ...
## - attr(*, "spec")=
## .. cols(
## .. `Starting Year` = col_double(),
## .. Rank = col_double(),
## .. Team = col_character(),
## .. `Home: Total Games` = col_double(),
## .. `Home: Total Attendance` = col_number(),
## .. `Home: Avg Attendance` = col_number(),
## .. `Home: % Capactiy` = col_double(),
## .. `Away: Total Games` = col_double(),
## .. `Away: Total Attendance` = col_number(),
## .. `Away: Avg Attendance` = col_double(),
## .. `Away: % Capactiy` = col_double(),
## .. Arena = col_character(),
## .. Latitude = col_double(),
## .. Longitude = col_double()
## .. )
This dataset has 16 variables: Year, Rank, Team, Total Games: Home and Away, Total Attendance: Home and Away, Percent Capacity: Home and Away, the name of the arena, and its location(longitude and latitude). For this project, the Team, Arena, Average Attendance, and Home Capacity variables were used.
To add a little extra to the interactive map, I replaced the default marker icon with the NBA logo.
NBAicon <- makeIcon(
iconUrl = "/Users/ohb544/Desktop/r94wkw_large.png",
iconWidth = 20, iconHeight = 30
)
NBA %>%
leaflet()%>%
addTiles()%>%
addMarkers(data = NBA, icon = NBAicon, popup = paste("Team:", NBA$Team, "<br>",
"Arena:", NBA$Arena, "<br>",
"Average Attendance:", NBA$`Home: Avg Attendance`, "<br>",
"Home Capacity:", NBA$`Home: % Capactiy`,"<br>"))
## Assuming "Longitude" and "Latitude" are longitude and latitude, respectively
In this project, NBA attendance data from the 2013-2014 season was displayed using Leaflet. It is interesting to compare this data to attendance data from the current season to see what has changed in just five years. For the most part, NBA attendance, like most sports, is correlated with how well the team performs. One of the biggest jumps belongs to the Philadelphia 76ers, who in 2014 had an average home capacity of 68.6%. In 2019, according to ESPN, the average home capacity shot to 100.6%. Another big jump was made by the Denver Nuggets, who went from 76.7% to 96.3%. The 76ers finished 3rd in the East and the Nuggets 2nd in the West. The Warriors and Thunder show that if you can be consistently good, so will your attendance. Both teams had 100% average home capacity in 2014 and 2019. When it comes to NBA attendance, the old adage appears to be true, winning does cure everything.