hoopR

hoopR is an R package for working with men’s basketball data.

The package has functions to access live play by play and box score data from ESPN with shot locations when available.

It is additionally a scraping and aggregating interface for Ken Pomeroy’s men’s college basketball statistics website, kenpom.com. It provides users with an active subscription the capability to scrape the website tables and analyze the data for themselves.

Installation

You can install the released version of hoopR from GitHub with:

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("saiemgilani/hoopR")
# if you would prefer devtools installation
if (!requireNamespace('devtools', quietly = TRUE)){
  install.packages('devtools')
}
# Alternatively, using the devtools package:
devtools::install_github(repo = "saiemgilani/hoopR")

Quick Start

NBA full play-by-play seasons (2002-2021) ~ 1-2 minutes

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("saiemgilani/hoopR")
future::plan("multisession")
tictoc::tic()
progressr::with_progress({
  pbp <- load_nba_pbp(2002:2021)
})
tictoc::toc()
## 66.99 sec elapsed
length(unique(pbp$game_id))
nrow(pbp)

Men’s college basketball full play-by-play seasons (2002-2021) ~ 2-3 minutes

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("saiemgilani/hoopR")
future::plan("multisession")
tictoc::tic()
progressr::with_progress({
  pbp <- load_mbb_pbp(2002:2021)
})
tictoc::toc()

## 135.87 sec elapsed
length(unique(pbp$game_id))
nrow(pbp)

Documentation

For more information on the package and function reference, please see the hoopR documentation website.

Breaking Changes

Full News on Releases

hoopR 1.1.0

Add team box score loaders

Add player box score loaders

View more version news

hoopR 1.0.4

Add retry

  • Adding httr::retry() to all function calls to more naturally navigate rejected/failed requests from the API.

hoopR 1.0.2-3

Quick fix for update db functions

hoopR 1.0.1

Dependency pruning

This update is a non-user facing change to package dependencies to shrink the list of dependencies.

hoopR 1.0.0

Package renamed to hoopR

To reflect that the package is no longer just a men’s college basketball and KenPom package, but also an NBA package.

Clean names and team returns

Loading capabilities added to the package

hoopR 0.4

hoopR 0.3.0

  • R version 3.5.0 or greater dependency added
  • purrr version 0.3.0 or greater dependency added
  • rvest version 1.0.0 or greater dependency added
  • progressr version 0.6.0 or greater dependency added
  • usethis version 1.6.0 or greater dependency added
  • xgboost version 1.1.0 or greater dependency added
  • tidyr version 1.0.0 or greater dependency added
  • stringr version 1.3.0 or greater dependency added
  • tibble version 3.0.0 or greater dependency added
  • furrr dependency added
  • future dependency added

Test coverage

  • Added tests for all KP and ESPN functions

Function Naming Convention Change

  • All functions sourced from kenpom.com will start with kp_ as opposed to get_

  • Similarly, data and metrics sourced from ESPN will begin with espn_ as opposed to cbb_. Moreover, all references to cbb_ have been changed to mbb_ as appropriate.

  • Data sourced directly from the NCAA website will start the function with ncaa_

New in v0.2.0-3: Support for ESPN’s men’s college basketball game data and NCAA NET Rankings

See the following four eight functions:

Current Issues

issue icon title labels opened_by date closed
NA NA NA NA NA NA NA

View More

issue icon title labels opened_by date closed
14 Error in “update_nba_db”: could not find function “my_time” jedwards757 2021-05-20 2021-05-20 22:53:32
1 gameplan function error bug mcoleman9221 2021-01-28 2021-01-28 03:31:48
18 team/player boxes saiemgilani 2021-05-31 2021-05-31 07:34:30
17 standings saiemgilani 2021-05-22 2021-05-22 11:11:07
11 add load_mbb_pbp() and load_nba_pbp() functions saiemgilani 2021-05-12 2021-05-17 23:35:12


Our Authors