knitr::opts_chunk$set(echo = TRUE)
install.packages("tidyverse", repos = "http://cran.us.r-project.org")
library(tidyverse)
library(readxl)

NBA <- read_excel("C:/Users/macks/Documents/Spring 2021 Classes/Stat Computing/NBA_Wins_1.xlsx", sheet= "Stats")

max_wins_per_year <- NBA %>% group_by(Year) %>% summarise(max_wins = max(Total_Wins), min_wins = min(Total_Wins))
max_wins_per_year


max_wins_per_year_graph = ggplot(data=max_wins_per_year, aes(x=substr(Year,6,8), y=max_wins, group=1)) +
  geom_line(color="blue", size=1)+
  geom_point(color="blue")+
  ggtitle("Most Wins Per Year") + labs(x="Year", y="Highest Number of Wins")

max_wins_per_year_graph

Visualization Description

As a big NBA fan, I wanted to look at an NBA dataset for this assignment.The data I used comes from www.basketball-reference.com, a website run by Sports Reference that includes up to date, publicly available sports data. This dataset includes a lot of statistics on every NBA team from the 2004-05 season through the 2019-20 season, including total wins in the season.

I was interested in understanding what was the highest number of wins during each season to uncover if this is something that fluctuates heavily in the league. I know each team plays 82 games per season, and I was curious to see how many of those games the “best” team won each season. The above line chart clearly shows this by illustrating the maximum number of wins over the 2004-05 - 2019-20 seasons. Interestingly enough, it appears like the team that wins the most games wins between 55-67 games. After seeing the large dip in 2012 to only 50 games won, I researched it and realized that the season in 2011-12 was shortened to 66 games because of a player’s strike surrounding salary negotiations.