Learn R Programming

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. As of version 1.3.0, hoopR is also a full NBA Stats API wrapper with 127 functions added in this release.

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 CRAN version of hoopR with:

install.packages("hoopR")

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("sportsdataverse/hoopR", dependencies = TRUE, update = TRUE)

Quick Start

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

tictoc::tic()
progressr::with_progress({
  nba_pbp <- hoopR::load_nba_pbp()
})
tictoc::toc()
## 1.02 sec elapsed

## 109783 rows of NBA play-by-play data from 230 games.

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

tictoc::tic()
progressr::with_progress({
  mbb_pbp <-  hoopR::load_mbb_pbp()
})
tictoc::toc()
## 1.62 sec elapsed

## 360517 rows of men's college basketball play-by-play data from 1074 games.

Documentation

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

Breaking Changes

Full News on Releases

Follow the SportsDataverse (@SportsDataverse) on Twitter and star this repo

Our Authors

  • Saiem Gilani (@saiemgilani)

Our Contributors (they’re awesome)

  • Jason Lee (@theFirmAISports)

  • Billy Fryer (@_b4billy_)

  • Ross Drucker (@rossdrucker9)

  • Vladislav Shufinskiy (@vshufinskiy)

Citations

To cite the hoopR R package in publications, use:

BibTex Citation

@misc{gilani_2021_hoopR,
  author = {Gilani, Saiem},
  title = {hoopR: The SportsDataverse's R Package for Men's Basketball Data.},
  url = {https://hoopR.sportsdataverse.org},
  year = {2021}
}

Copy Link

Version

Install

install.packages('hoopR')

Monthly Downloads

1,259

Version

2.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Saiem Gilani

Last Published

November 25th, 2023

Functions in hoopR (2.1.0)

check_status

Check Status function
.players_on_court

Add players on court in NBA Stats API play-by-play
espn_mbb_conferences

Get ESPN conference names and IDs
clean_team_names_NCAA_merge

Clean KenPom Data Frame Team Names to match NCAA Team Names for easier merging
csv_from_url

Load .csv / .csv.gz file from a remote connection
espn_mbb_player_box

Get ESPN men's college basketball player box scores
espn_mbb_game_rosters

Get ESPN men's college basketball game rosters
espn_mbb_betting

Get ESPN MBB's Betting information
espn_mbb_pbp

Get ESPN men's college basketball PBP data
espn_mbb_game_all

Get ESPN men's college basketball data (Pbp, Team and Player Box)
espn_mbb_scoreboard

Get ESPN men's college basketball schedule for a specific year
espn_mbb_wp

Men's College Basketball win probability chart data from ESPN
espn_mbb_player_stats

Get ESPN men's college basketball player stats data
espn_mbb_team_stats

Get ESPN men's college basketball team stats data
espn_mbb_team_box

Get ESPN men's college basketball team box scores
espn_mbb_teams

Get ESPN men's college basketball team names and IDs
espn_nba_betting

Get ESPN NBA's Betting information
espn_mbb_standings

Get ESPN men's college basketball standings
espn_nba_game_all

Get ESPN NBA game data (Pbp, Team and Player Box)
espn_mbb_rankings

Get men's college basketball AP and Coaches Poll rankings from ESPN
espn_nba_team_stats

Get ESPN NBA team stats data
espn_nba_team_box

Get ESPN NBA team box scores
espn_nba_game_rosters

Get ESPN NBA game rosters
espn_nba_player_box

Get ESPN NBA player box scores
espn_nba_player_stats

Get ESPN NBA player stats data
helper_espn_nba_player_box

Parse ESPN NBA Player Box, helper function
helper_espn_mbb_pbp

Parse ESPN MBB PBP, helper function
espn_nba_teams

Get ESPN NBA team names and IDs
espn_nba_scoreboard

Get ESPN NBA schedule for a specific year
helper_espn_nba_team_box

Parse ESPN NBA Team Box, helper function
espn_nba_pbp

Get ESPN NBA PBP data
kp_gameplan

Get KenPom's team game plan page
helper_espn_mbb_player_box

Parse ESPN MBB Player Box, helper function
kp_hca

Get Home Court Advantage Estimates
kp_box

Get KenPom Game Box Score
kp_pomeroy_archive_ratings

Get KenPom's ratings archive pages
kp_coach_history

Get KenPom's coaching resume data
kp_fanmatch

Get FanMatch by date
kp_conf

Get KenPom's conference-wide stats
kp_game_attrs

Get Game Attributes
espn_nba_wp

Get NBA win probability chart data from ESPN
kp_fourfactors

Get Four Factors Data
helper_espn_mbb_team_box

Parse ESPN MBB Team Box, helper function
kp_foul_trouble

Get 2-Foul Participation Stats
kp_pomeroy_ratings

Get KenPom Ratings
kp_program_ratings

Get KenPom's program ratings
helper_espn_nba_pbp

Parse ESPN NBA PBP, helper function
kp_confstats

Get KenPom's conference comparison stats
hoopR-package

hoopR: Access Men's Basketball Play by Play Data
espn_nba_standings

Get ESPN NBA's Standings
kp_confhistory

Get KenPom's historical conference ratings
kp_efficiency

Get KenPom Efficiency and Tempo Summary
kp_team_depth_chart

Get Depth Chart Last 5 Games from Team Page
kp_opptracker

Get KenPom's team opponent tracker page
kp_minutes_matrix

Get Minutes Matrix from Expanded Player Page
kp_officials

Get officials rankings
kp_teamstats

Get Team Stats
kp_trends

Get Division-I statistical trends
load_mbb_schedule

Load hoopR men's college basketball schedule
load_mbb_team_box

Load hoopR men's college basketball team box scores
kp_referee

Get referee game log
nba_boxscoredefensivev2

Get NBA Stats API Boxscore Defensive V2
kp_arenas

Get Home Court Arenas
kp_playerstats

Get Player Stats Leaders by Metric
nba_boxscorefourfactorsv3

Get NBA Stats API Boxscore Four Factors V3
nba_boxscorefourfactorsv2

Get NBA Stats API Boxscore Four Factors V2
kp_player_career

Get KenPom's player career stats from the player page
kp_pointdist

Get Team Points Distribution
nba_boxscorescoringv2

Get NBA Stats API Boxscore Scoring V2
kp_team_players

Get KenPom's player stats from the team page
kp_team_history

Get KenPom's team efficiency history
nba_boxscorescoringv3

Get NBA Stats API Boxscore Scoring V3
kp_user_pw

KenPom Login and Password credentials
nba_boxscoresimilarityscore

Get NBA Stats API Boxscore Similarity Score
nba_boxscorehustlev2

Get NBA Stats API Boxscore Hustle V2
most_recent_nba_season

Most Recent NBA Season
most_recent_mbb_season

Most Recent Men's College Basketball Season
load_mbb_pbp

Load hoopR men's college basketball play-by-play
kp_kpoy

Get KPoY Leaders Tables
nba_boxscoremiscv2

Get NBA Stats API Boxscore Misc V2
nba_boxscoremiscv3

Get NBA Stats API Boxscore Misc V3
load_mbb_player_box

Load hoopR men's college basketball player box scores
nba_alltimeleadersgrids

Get NBA Stats API All-time Leaders Grid
nba_commonplayoffseries

Get NBA Stats API Playoff Series
nba_draftboard

Get NBA Stats API Draft Board
nba_assistleaders

Get NBA Stats API Assist Leaders
kp_height

Get Heights, Experience, Bench and Continuity Data
nba_commonteamroster

Get NBA Stats API Team Roster
kp_team_lineups

Get Lineups Last 5 Games from Team Page
kp_winprob

Get KenPom Win Probability
kp_team_player_stats

Get Team Player Stats
nba_draftcombinedrillresults

Get NBA Stats API Draft Combine Drill Results
kp_team_schedule

Get team schedule results
nba_boxscoresummaryv2

Get NBA Stats API Boxscore Summary V2
nba_data_pbp

Get NBA Data API Play-by-Play
load_nba_pbp

Load hoopR NBA play-by-play
load_nba_schedule

Load hoopR NBA schedules
nba_defensehub

Get NBA Stats API Defense Hub
nba_draftcombinestats

Get NBA Stats API Draft Combine Stats
nba_draftcombinespotshooting

Get NBA Stats API Draft Combine - Spot Shooting
load_nba_team_box

Load hoopR NBA team box scores
nba_boxscoreplayertrackv2

Get NBA Stats API Boxscore Player Tracking V2
load_nba_player_box

Load hoopR NBA player box scores
nba_leaderstiles

Get NBA Stats API Leaders Tiles
nba_leaguedashlineups

Get NBA Stats API League Dashboard Lineups
nba_assisttracker

Get NBA Stats API Assist Tracker
nba_boxscorematchupsv3

Get NBA Stats API Boxscore Matchups V3
nba_boxscoreadvancedv2

Get NBA Stats API Boxscore Advanced V2
nba_boxscorematchups

Get NBA Stats API Boxscore Matchups
nba_commonallplayers

Get NBA Stats API All Players
nba_commonplayerinfo

Get NBA Stats API Player Info
nba_boxscoreadvancedv3

Get NBA Stats API Boxscore Advanced V3
nba_boxscoreusagev2

Get NBA Stats API Boxscore Usage V2
nba_boxscoredefensive

Get NBA Stats API Boxscore Defensive
nba_boxscoreusagev3

Get NBA Stats API Boxscore Usage V3
nba_leaguedashptdefend

Get NBA Stats API League Dashboard Player Tracking - Defense
nba_cumestatsteam

Get NBA Stats API Cumulative Team Stats
nba_leaguedashptstats

Get NBA Stats API League Dashboard Player Tracking - Stats
nba_cumestatsteamgames

Get NBA Stats API Cumulative Team Game Stats
nba_leaguedashplayerptshot

Get NBA Stats API League Dashboard Player Tracking - Player Shots
nba_fantasywidget

Get NBA Stats API Fantasy Widget
nba_drafthistory

Get NBA Stats API Draft History
nba_leaguedashplayerclutch

Get NBA Stats API League Dashboard by Player Clutch Splits
nba_boxscoreplayertrackv3

Get NBA Stats API Boxscore Player Tracking V3
nba_draftcombinenonstationaryshooting

Get NBA Stats API Draft Combine Non-Stationary Shooting
nba_leaguedashplayershotlocations

Get NBA Stats API League Dashboard Player Shot Locations
nba_leaguestandings

Get NBA Stats API League Standings
nba_leaguedashplayerstats

Get NBA Stats API League Dashboard Player Stats
nba_leagueseasonmatchups

Get NBA Stats API League Season Matchups
nba_boxscoretraditionalv2

Get NBA Stats API Boxscore Traditional V2
nba_boxscoretraditionalv3

Get NBA Stats API Boxscore Traditional V3
nba_cumestatsplayer

Get NBA Stats API Cumulative Player Stats
nba_gamerotation

Get NBA Stats API Game Rotation
nba_franchiseleaderswrank

Get NBA Stats API Franchise Leaders with Rank
nba_homepageleaders

Get NBA Stats API Homepage Leaders
nba_leaguehustlestatsplayerleaders

Get NBA Stats API League Hustle Stats Player Leaders
nba_franchiseplayers

Get NBA Stats API Franchise Players
nba_draftcombineplayeranthro

Get NBA Stats API Draft Combine Player Anthropological Measurements
nba_homepagev2

Get NBA Stats API HomepageV2 Leaders
nba_leaguedashteamstats

Get NBA Stats API League Dashboard Team Stats
nba_cumestatsplayergames

Get NBA Stats API Cumulative Player Game Stats
nba_franchiseleaders

Get NBA Stats API Franchise Leaders
nba_franchisehistory

Get NBA Stats API Franchise History
nba_hustlestatsboxscore

Get NBA Stats API Hustle Stats Boxscore
nba_infographicfanduelplayer

Get NBA Stats API FanDuel Player Infographic
nba_playercareerbycollegerollup

Get NBA Stats API Player Career By College Rollup
nba_leaguehustlestatsteam

Get NBA Stats API League Hustle Stats Team
nba_playerawards

Get NBA Stats API Player Awards
nba_leaguegamefinder

Get NBA Stats API League Game Streak Finder
nba_glalumboxscoresimilarityscore

Get NBA Stats API G-League Alum Boxscore Similarity Score
nba_playercareerstats

Get NBA Stats API Player Career Stats
nba_leaguedashteamclutch

Get NBA Stats API League Dashboard by Team Clutch Splits
nba_leaguehustlestatsplayer

Get NBA Stats API League Hustle Stats Player
nba_leaguedashplayerbiostats

Get NBA Stats API League Dashboard Player Biographical Stats
nba_leaguegamelog

Get NBA Stats API League Game Log
nba_leaguedashoppptshot

Get NBA Stats API League Dashboard Player Tracking - Opponent Shots
nba_leaguehustlestatsteamleaders

Get NBA Stats API League Hustle Stats Team Leaders
nba_leaguedashptteamdefend

Get NBA Stats API League Dashboard Player Tracking - Team Defense
nba_leaguestandingsv3

Get NBA Stats API League Standings V3
nba_playercareerbycollege

Get NBA Stats API Player Career By College
nba_live_boxscore

Get NBA Stats API Live Boxscore
nba_leagueleaders

Get NBA Stats API League Leaders
nba_matchupsrollup

Get NBA Stats API Matchups Rollup
nba_live_pbp

Get NBA Stats API Live play-by-play
nba_leaguedashteamptshot

Get NBA Stats API League Dashboard Player Tracking - Team Shots
nba_leaguedashteamshotlocations

Get NBA Stats API League Dashboard Team Shot Locations
nba_leagueplayerondetails

Get NBA Stats API League Player On/Off Details
nba_leaguelineupviz

Get NBA Stats API League Lineup Visual Data
nba_pbps

Get NBA Stats API play-by-play (Multiple Games)
nba_pbp

Get NBA Stats API play-by-play