Skip to content

An R package to quickly obtain clean and tidy men's basketball play by play data.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

sportsanalytics-world/hoopR

 
 

Repository files navigation

hoopR

Version-Number R-CMD-check Lifecycle:maturing Twitter Follow Contributors

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.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

View more version news

hoopR 0.4

  • Added support for ESPN’s NBA play-by-play endpoints with the addition of the following functions:
  • hoopR::espn_nba_game_all() - a convenience wrapper function around the following three functions (returns the results as a list of three data frames)
  • hoopR::espn_nba_team_box()
  • hoopR::espn_nba_player_box()
  • hoopR::espn_nba_pbp()
  • hoopR::espn_nba_teams()
  • hoopR::espn_nba_scoreboard()

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
16 add retry saiemgilani 2021-05-21 2021-05-21 09:09:54
15 my_time bug saiemgilani 2021-05-20 2021-05-20 19:32:20
13 dependency pruning the functions saiemgilani 2021-05-20 2021-05-20 13:52:01

Our Authors

About

An R package to quickly obtain clean and tidy men's basketball play by play data.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 99.0%
  • CSS 1.0%