knitr::opts_chunk$set(echo = TRUE)
old <- options(rmarkdown.html_vignette.check_title = FALSE)

pkg_name <- "sportsdataverse/hoopR"
url <- paste0("https://raw.githubusercontent.com/", pkg_name, "/main/DESCRIPTION")


x <- readLines(url)
remote_version <- gsub("Version:\\s*", "", x[grep('Version:', x)])

Welcome folks,

I'm Saiem Gilani, one of the authors of hoopR, and I hope to give the community a high-quality resource for accessing men's basketball data for statistical analysis, basketball research, and more. I am excited to show you some of what you can do with this edition of the package.

Installing R and RStudio

  1. Head to https://cran.r-project.org
  2. Select the appropriate link for your operating system (Windows, Mac OS X, or Linux)

  3. Windows - Select base and download the most recent version

  4. Mac OS X - Select Latest Release, but check to make sure your OS is the correct version. Look through Binaries for Legacy OS X Systems if you are on an older release
  5. Linux - Select the appropriate distro and follow the installation instructions

  6. Head to RStudio.com

  7. Follow the associated download and installation instructions for RStudio.
  8. Start peering over the RStudio IDE Cheatsheet. An IDE is an integrated development environment.
  9. For Windows users: I recommend you install Rtools. This is not an R package! It is “a collection of resources for building packages for R under Microsoft Windows, or for building R itself”. Go to https://cran.r-project.org/bin/windows/Rtools/ and follow the directions for installation.

Install hoopR

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("sportsdataverse/hoopR", dependencies = TRUE, update = TRUE)

pacman::p_load(dplyr, zoo, ggimage, gt)

The Data

There are generally speaking six men's basketball data sources accessed from this package:

Function names indicate the data source

Quick Start

For the sake of your R session, we will only look at the previous 3 years of data, but I have indicated the years to which the data goes back to.

NBA play-by-plays (2002-r hoopR::most_recent_nba_season()) ~ 60-120 seconds

tictoc::tic()
progressr::with_progress({
  nba_pbp <- hoopR::load_nba_pbp(2021:hoopR::most_recent_nba_season())
})
tictoc::toc()
glue::glue("{nrow(nba_pbp)} rows of nba play-by-play data from {length(unique(nba_pbp$game_id))} games.")
dplyr::glimpse(nba_pbp)

NBA team box scores (2002-r hoopR::most_recent_nba_season()) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  nba_team_box <- hoopR::load_nba_team_box(2021:hoopR::most_recent_nba_season())
})

tictoc::toc()

glue::glue("{nrow(nba_team_box)} rows of NBA team boxscore data from {length(unique(nba_team_box$game_id))} games.")
dplyr::glimpse(nba_team_box)

NBA player box scores (2002-r hoopR::most_recent_nba_season()) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  nba_player_box <- hoopR::load_nba_player_box(2021:hoopR::most_recent_nba_season())
})
tictoc::toc()

glue::glue("{nrow(nba_player_box)} rows of NBA player boxscore data from {length(unique(nba_player_box$game_id))} games.")
dplyr::glimpse(nba_player_box)

Men's college basketball play-by-plays (2006-r hoopR::most_recent_mbb_season()) ~ 120-180 seconds

tictoc::tic()
progressr::with_progress({
  mbb_pbp <- hoopR::load_mbb_pbp(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()
glue::glue("{nrow(mbb_pbp)} rows of men's college basketball play-by-play data from {length(unique(mbb_pbp$game_id))} games.")
dplyr::glimpse(mbb_pbp)

Men's college basketball team box scores (2003-r hoopR::most_recent_mbb_season()) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  mbb_team_box <- hoopR::load_mbb_team_box(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()
glue::glue("{nrow(mbb_team_box)} rows of men's college basketball team boxscore data from {length(unique(mbb_team_box$game_id))} games.")
dplyr::glimpse(mbb_team_box)

Men's college basketball player box scores (2003-r hoopR::most_recent_mbb_season()) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  mbb_player_box <- hoopR::load_mbb_player_box(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()

glue::glue("{nrow(mbb_player_box)} rows of men's college basketball player boxscore data from {length(unique(mbb_player_box$game_id))} games.")
dplyr::glimpse(mbb_player_box)

Our Authors

Our Contributors (they're awesome)



saiemgilani/kenpomR documentation built on Dec. 10, 2023, 3:34 a.m.