Simple Interactive Visualization of '16-17 NBA Stats With Shiny

Posted on Jun 9, 2018


Why I Chose This Project

Fantasy sports is a multi-billion-dollar industry. Most people play in leagues as an effective way to stay connected to friends, co-workers, and family through friendly competition. Most of us don't have enough time in our lives to stay current with all the updates and latest news about the sports we have interest in. To reconcile this challenge, I practiced my skills I developed in R to build a Shiny App that compiles in-depth stats on NBA players.

Questions to Answer

I set out to answer which players had the most values in multiple categories. I wanted to discover some of the mid-tier players in the ’16-’17 season that stood out in certain statistical categories to keep on my radar for next season.


Where and How I Extracted the Data

To gather the data I needed, I first had to search the web and figure out what would would be the most efficient way to extract the stats. There are many websites that display NBA stats but most of them don’t make it simple to download to a .csv or .txt file. I discovered which had the relevant stats in a simple raw downloadable .txt file. The .txt files still needed a fair amount of data munging to tidy up for usage within the Shiny App.

I also extracted advanced stats from which included further statistics for the guard, forward, and center positions in the NBA. Since the advanced stats were in tables already, the most efficient way to extract the data was to use Pandas read_html method. Some of the tables extracted with Pandas were missing the column names so I used BeautifulSoup to extract them and combine them with the Pandas dataframe. I then exported it as a .csv file.

How I analyzed the data

Before I set up my Shiny App, I wanted to answer the following questions using dplyr:

#1. What is the correlation between minutes and primary stats?

Unsurprisingly there is a strong correlation between how many minutes are played and the primary statistics such as points, assists, rebounds, etc.

You can find the remainder of this answer in my GitHub repo.

#2. What is the mean and SD of primary stats. Per team? Per position?

You can find the remainder of this answer in my GitHub repo.

#3. Which players have the best PER's in the league per team? Per position? Per position on team?

#4. What is each team’s total PER?

#5. What are the central tendencies of primary stats? Per team? Per Position?

You can find the remainder of this answer in my GitHub repo.

#6. Who were the league leaders in primary stats?

#7. What was each team’s winning percentage?

#8.What is the correlation between team PER and team win ratio?

How I Visualized The Data

I created the app to display multiple data tables. A search for whatever keyword the user finds applicable (ie, player name, team name, position, stats category) is simple. The app also displays an interactive visualization of the correlation between team PER (player efficiency rating) and team winning percentage.


Insights Gleaned

There didn't appear to be a clear correlation between team PER and team winning percentage.

A few players, when doing my analysis, appeared to offer solid value adds in later rounds of a draft; these players excelled at one or a few important categories but are generally overlooked because of their total minutes per game since they play behind more well-known star players.

The analysis helped me to narrow my focus on specific players so I can pay closer attention to what happens to their career next season. Sometimes a trade to a new team can increase a mid-tier players value if they have already shown promise playing behind another star player.

Improvement to be Made

This was a small-scale project that completed in the offseason. I only analyzed data from ’16-’17 season. Gleaning insights from the data of the previous season can be helpful, but many more intangible variables off the court or field are necessary to come to a confident decision about adding a player to my fantasy team. It is also helpful to glean insights quickly and efficiently while the season is taking place. I may figure out how to extract and import data in a more efficient process as a next step in the project.

You can view the project here: and my code on GitHub here: It was interesting to learn R and Shiny but I have currently have no intention to use them again in the short term. You can view other interactive data visualizations I've created with Tableau here:


About Author

Keenan Burke-Pitts

Keenan has over 3 years of experience communicating and assisting in software and internet solutions to clients. Moving forward, Keenan plans to leverage his technical abilities, communication skills, and business understanding in the digital marketing world. Keenan graduated...
View all posts by Keenan Burke-Pitts >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp