/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 and 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
  • Plotting basketball and soccer shot charts from manually created event data
    • The tutorial shows how to create basketball and soccer shot charts using the sporty R package and plotting tools from @nguyenank_ and @Torvaney. This can be a great tool for coaches from either sport and at any age level by allowing you to create your own historical database and also by creating high-level visuals! basketball_shot_chartsoccer_shot_chart