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

Posted on Jun 9, 2018

Purpose

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, which is why they are recorded and kept as data. To reconcile this challenge, I practiced my skills I developed in R to build a Shiny App that compiles in-depth stats and compile data 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.

Process

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 http://www.dougstats.com/16-17.html 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 https://rotogrinders.com/pages/nba-advanced-player-stats-guards-181885 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.

Results

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: https://kiwibp.shinyapps.io/nbashiny/ and my code on GitHub here: https://github.com/Kiwibp/NYC-DSA-Bootcamp--R-Shiny-App. 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: https://public.tableau.com/profile/keenan.burke.pitts.

 

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 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis 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 seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI