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.
Select the appropriate link for your operating system (Windows, Mac OS X, or Linux)
Windows - Select base and download the most recent version
Linux - Select the appropriate distro and follow the installation instructions
Head to RStudio.com
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)
There are generally speaking six men's basketball data sources accessed from this package:
hoopR-data
repo Functions that use the hoopR-data
repository will contain load_
or update_
in the function name and would be considered loading functions for the play-by-play data, team box scores, and player box scores.
Functions that use the NBA Stats API start with nba_
by convention and should be assumed as get
functions. As of hoopR
version r remote_version
, the package exports 127 functions covering the NBA Stats API
Functions that use the NBA G-League Stats API start with nbagl_
by convention and should be assumed as get
functions. As of hoopR
version r remote_version
, the package exports 4 functions covering the NBA G-League Stats API
Functions that use one of ESPN's APIs start with espn_
by convention and should be assumed as get
functions. These functions allow for live access to game data for both men's college basketball and the NBA. As of hoopR
version r remote_version
, the package exports 10 functions covering the men's college basketball endpoints and 10 for the NBA.
Functions that use Ken Pomeroy's college basketball website start with kp_
by convention and should be assumed as get
functions. These functions allow users with an active subscription to get access to the data in a tidy format. As of hoopR
version r remote_version
, the package exports 36 functions covering the KenPom.com.
Functions that use the NCAA website start with ncaa_
by convention and should be assumed as get
functions. As of hoopR
version r remote_version
, the package exports 1 function(s) covering the NCAA website, namely the function to access current NET rankings.
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.
r hoopR::most_recent_nba_season()
) ~ 60-120 secondstictoc::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)
r hoopR::most_recent_nba_season()
) ~ 5-30 secondstictoc::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)
r hoopR::most_recent_nba_season()
) ~ 5-30 secondstictoc::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)
r hoopR::most_recent_mbb_season()
) ~ 120-180 secondstictoc::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)
r hoopR::most_recent_mbb_season()
) ~ 5-30 secondstictoc::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)
r hoopR::most_recent_mbb_season()
) ~ 5-30 secondstictoc::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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.