/R_Tutorials

Using packages to create shot charts generated in R Studio.

R_Tutorials

To complement my R tutorials on YouTube, this repository contains the R markdown files that contain the scripts I used to produce the visualizations in the videos. Those can be found here: https://www.youtube.com/playlist?list=PL10a1_q15Hwr4H5dCXQD3htK5VGfwjrgq.

The tutorials included are:

  • NBA and NCAA basketball shot charts utilizing the NBA API and ncaahoopR package.
    • The tutorial shows how to create a court, scrape player shot data, and finally plot and customize an aesthetcially pleasing shot chart. The finished products can be seen above in png form! Example_NBA_Shot_Chart_Durant
  • Using rvest to scrape baksetball-reference.com and fbref.com and then visualizing relationships using scatter plots.
    • The tutorial shows how to scrape indivudal tables from the aforementioned websites. We then utilizee ggplot2 to visualize the relationships between xG and xGA in the Premier League and offensive and defensive rating in the NBA. nba
  • Creating NBA shot and Soccer pass heatmaps using nbastatR and StatsBombR packages.
    • The tutorial shows how to create heatmaps for both NBA shots and Soccer/Football passes using geom_contour_2d_filled. FCrStats's SBPitch package is also used to plot a pitch and other customizable features are shown as well. CP3_Heatmap Example_Soccer_Heatmap
  • Creating NBA nd Soccer/Football poalr/pizza charts.
    • The tutorial shows how to create heatmaps for both NBA shots and Soccer/Football using a manually created data frame and scraping football reference scouting reports from the worldfootballR package. Example_Soccer_Polar Example_NBA_Polar