Skip to contents

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)
  • Windows - Select base and download the most recent version
  • 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
  • Linux - Select the appropriate distro and follow the installation instructions
  1. Head to RStudio.com
  2. Follow the associated download and installation instructions for RStudio.
  3. Start peering over the RStudio IDE Cheatsheet. An IDE is an integrated development environment.
  4. 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
  • 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 2.1.0, 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 2.1.0, 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 2.1.0, 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 2.1.0, 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 2.1.0, the package exports 1 function(s) covering the NCAA website, namely the function to access current NET rankings.

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-2024) ~ 60-120 seconds

tictoc::tic()
progressr::with_progress({
  nba_pbp <- hoopR::load_nba_pbp(2021:hoopR::most_recent_nba_season())
})
tictoc::toc()
## 16.368 sec elapsed
glue::glue("{nrow(nba_pbp)} rows of nba play-by-play data from {length(unique(nba_pbp$game_id))} games.")
## 1894267 rows of nba play-by-play data from 4048 games.
dplyr::glimpse(nba_pbp)
## Rows: 1,894,267
## Columns: 64
## $ id                              <dbl> 4013441404, 4013441407, 4013441408, 40…
## $ sequence_number                 <chr> "4", "7", "8", "10", "11", "12", "14",…
## $ type_id                         <int> 615, 131, 155, 131, 155, 109, 155, 145…
## $ type_text                       <chr> "Jumpball", "Pullup Jump Shot", "Defen…
## $ text                            <chr> "Deandre Ayton vs. Brook Lopez (Devin …
## $ away_score                      <int> 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,…
## $ home_score                      <int> 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2,…
## $ period_number                   <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ period_display_value            <chr> "1st Quarter", "1st Quarter", "1st Qua…
## $ clock_display_value             <chr> "12:00", "11:40", "11:39", "11:21", "1…
## $ scoring_play                    <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FAL…
## $ score_value                     <int> 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0,…
## $ team_id                         <int> 21, 21, 15, 15, 21, 21, 15, 15, 21, 15…
## $ athlete_id_1                    <int> 4278129, 2779, 3032977, 3995, 6581, 31…
## $ athlete_id_2                    <int> 3448, NA, NA, NA, NA, 3032977, NA, 660…
## $ wallclock                       <chr> "2021-07-21T01:11:29Z", "2021-07-21T01…
## $ shooting_play                   <lgl> FALSE, TRUE, FALSE, TRUE, FALSE, TRUE,…
## $ coordinate_x_raw                <dbl> -214748340, 30, 30, 6, 6, 25, 25, 28, …
## $ coordinate_y_raw                <dbl> -214748365, 19, 19, 5, 5, 4, 4, 3, 12,…
## $ season                          <int> 2021, 2021, 2021, 2021, 2021, 2021, 20…
## $ season_type                     <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,…
## $ away_team_id                    <int> 21, 21, 21, 21, 21, 21, 21, 21, 21, 21…
## $ away_team_name                  <chr> "Phoenix", "Phoenix", "Phoenix", "Phoe…
## $ away_team_mascot                <chr> "Suns", "Suns", "Suns", "Suns", "Suns"…
## $ away_team_abbrev                <chr> "PHX", "PHX", "PHX", "PHX", "PHX", "PH…
## $ away_team_name_alt              <chr> "Phoenix", "Phoenix", "Phoenix", "Phoe…
## $ home_team_id                    <int> 15, 15, 15, 15, 15, 15, 15, 15, 15, 15…
## $ home_team_name                  <chr> "Milwaukee", "Milwaukee", "Milwaukee",…
## $ home_team_mascot                <chr> "Bucks", "Bucks", "Bucks", "Bucks", "B…
## $ home_team_abbrev                <chr> "MIL", "MIL", "MIL", "MIL", "MIL", "MI…
## $ home_team_name_alt              <chr> "Milwaukee", "Milwaukee", "Milwaukee",…
## $ home_team_spread                <dbl> 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5…
## $ game_spread                     <dbl> -4.5, -4.5, -4.5, -4.5, -4.5, -4.5, -4…
## $ home_favorite                   <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…
## $ game_spread_available           <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…
## $ game_id                         <int> 401344140, 401344140, 401344140, 40134…
## $ qtr                             <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ time                            <chr> "12:00", "11:40", "11:39", "11:21", "1…
## $ clock_minutes                   <int> 12, 11, 11, 11, 11, 11, 11, 11, 10, 10…
## $ clock_seconds                   <dbl> 0, 40, 39, 21, 20, 14, 13, 6, 48, 24, …
## $ half                            <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ game_half                       <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ lead_qtr                        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ lead_game_half                  <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ start_quarter_seconds_remaining <dbl> 720, 700, 699, 681, 680, 674, 673, 666…
## $ start_half_seconds_remaining    <dbl> 1320, 1300, 1299, 1281, 1280, 1274, 12…
## $ start_game_seconds_remaining    <dbl> 2520, 2500, 2499, 2481, 2480, 2474, 24…
## $ game_play_number                <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,…
## $ end_quarter_seconds_remaining   <dbl> 600, 720, 700, 699, 681, 680, 674, 673…
## $ end_half_seconds_remaining      <dbl> 1200, 1320, 1300, 1299, 1281, 1280, 12…
## $ end_game_seconds_remaining      <dbl> 2400, 2520, 2500, 2499, 2481, 2480, 24…
## $ period                          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ lag_qtr                         <int> NA, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ lag_game_half                   <chr> NA, "1", "1", "1", "1", "1", "1", "1",…
## $ athlete_id_3                    <int> 3136193, NA, NA, NA, NA, NA, NA, NA, N…
## $ coordinate_x                    <dbl> -214748406.75, -22.75, 22.75, 36.75, -…
## $ coordinate_y                    <dbl> -214748365, 5, -5, 19, -19, 0, 0, -3, …
## $ game_date                       <date> 2021-07-20, 2021-07-20, 2021-07-20, 2…
## $ game_date_time                  <dttm> 2021-07-20 21:00:00, 2021-07-20 21:00…
## $ type_abbreviation               <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ home_timeout_called             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ away_timeout_called             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lead_half                       <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lag_half                        <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

NBA team box scores (2002-2024) ~ 5-30 seconds

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

tictoc::toc()
## 3.579 sec elapsed
glue::glue("{nrow(nba_team_box)} rows of NBA team boxscore data from {length(unique(nba_team_box$game_id))} games.")
## 8096 rows of NBA team boxscore data from 4048 games.
dplyr::glimpse(nba_team_box)
## Rows: 8,096
## Columns: 57
## $ game_id                           <int> 401344140, 401344140, 401344139, 401…
## $ season                            <int> 2021, 2021, 2021, 2021, 2021, 2021, …
## $ season_type                       <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, …
## $ game_date                         <date> 2021-07-20, 2021-07-20, 2021-07-17,…
## $ game_date_time                    <dttm> 2021-07-20 21:00:00, 2021-07-20 21:…
## $ team_id                           <int> 21, 15, 15, 21, 21, 15, 21, 15, 15, …
## $ team_uid                          <chr> "s:40~l:46~t:21", "s:40~l:46~t:15", …
## $ team_slug                         <chr> "phoenix-suns", "milwaukee-bucks", "…
## $ team_location                     <chr> "Phoenix", "Milwaukee", "Milwaukee",…
## $ team_name                         <chr> "Suns", "Bucks", "Bucks", "Suns", "S…
## $ team_abbreviation                 <chr> "PHX", "MIL", "MIL", "PHX", "PHX", "…
## $ team_display_name                 <chr> "Phoenix Suns", "Milwaukee Bucks", "…
## $ team_short_display_name           <chr> "Suns", "Bucks", "Bucks", "Suns", "S…
## $ team_color                        <chr> "23006a", "003813", "003813", "23006…
## $ team_alternate_color              <chr> "f1f2f3", "f0ebd2", "f0ebd2", "f1f2f…
## $ team_logo                         <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ team_home_away                    <chr> "away", "home", "away", "home", "awa…
## $ team_score                        <int> 98, 105, 123, 119, 103, 109, 100, 12…
## $ team_winner                       <lgl> FALSE, TRUE, TRUE, FALSE, FALSE, TRU…
## $ assists                           <int> 14, 20, 26, 23, 18, 22, 21, 28, 21, …
## $ blocks                            <int> 4, 6, 1, 5, 9, 3, 3, 2, 7, 2, 2, 1, …
## $ defensive_rebounds                <int> 31, 42, 26, 27, 35, 31, 30, 34, 28, …
## $ fast_break_points                 <chr> "11", "11", "21", "12", "0", "15", "…
## $ field_goal_pct                    <dbl> 44.2, 45.1, 57.5, 55.2, 51.3, 40.2, …
## $ field_goals_made                  <int> 38, 37, 50, 48, 40, 39, 40, 43, 42, …
## $ field_goals_attempted             <int> 86, 82, 87, 87, 78, 97, 83, 90, 93, …
## $ flagrant_fouls                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, …
## $ fouls                             <int> 21, 17, 17, 20, 24, 18, 24, 18, 17, …
## $ free_throw_pct                    <dbl> 84.2, 86.2, 52.9, 90.9, 84.2, 82.8, …
## $ free_throws_made                  <int> 16, 25, 9, 10, 16, 24, 11, 20, 15, 1…
## $ free_throws_attempted             <int> 19, 29, 17, 11, 19, 29, 16, 26, 23, …
## $ largest_lead                      <chr> "7", "13", "14", "16", "9", "8", "6"…
## $ offensive_rebounds                <int> 6, 11, 11, 8, 5, 17, 6, 13, 18, 11, …
## $ points_in_paint                   <chr> "44", "50", "46", "52", "40", "48", …
## $ steals                            <int> 11, 10, 7, 9, 3, 11, 3, 8, 8, 7, 4, …
## $ team_turnovers                    <int> 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, …
## $ technical_fouls                   <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, …
## $ three_point_field_goal_pct        <dbl> 24.0, 22.2, 50.0, 68.4, 30.4, 24.1, …
## $ three_point_field_goals_made      <int> 6, 6, 14, 13, 7, 7, 9, 14, 9, 20, 16…
## $ three_point_field_goals_attempted <int> 25, 27, 28, 19, 23, 29, 31, 36, 31, …
## $ total_rebounds                    <int> 37, 53, 37, 35, 40, 48, 36, 47, 46, …
## $ total_technical_fouls             <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, …
## $ total_turnovers                   <int> 15, 19, 12, 9, 17, 5, 15, 9, 9, 13, …
## $ turnover_points                   <chr> "10", "16", "17", "16", "24", "5", "…
## $ turnovers                         <int> 14, 18, 11, 8, 17, 5, 14, 9, 9, 12, …
## $ opponent_team_id                  <int> 15, 21, 21, 15, 15, 21, 15, 21, 21, …
## $ opponent_team_uid                 <chr> "s:40~l:46~t:15", "s:40~l:46~t:21", …
## $ opponent_team_slug                <chr> "milwaukee-bucks", "phoenix-suns", "…
## $ opponent_team_location            <chr> "Milwaukee", "Phoenix", "Phoenix", "…
## $ opponent_team_name                <chr> "Bucks", "Suns", "Suns", "Bucks", "B…
## $ opponent_team_abbreviation        <chr> "MIL", "PHX", "PHX", "MIL", "MIL", "…
## $ opponent_team_display_name        <chr> "Milwaukee Bucks", "Phoenix Suns", "…
## $ opponent_team_short_display_name  <chr> "Bucks", "Suns", "Suns", "Bucks", "B…
## $ opponent_team_color               <chr> "003813", "23006a", "23006a", "00381…
## $ opponent_team_alternate_color     <chr> "f0ebd2", "f1f2f3", "f1f2f3", "f0ebd…
## $ opponent_team_logo                <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ opponent_team_score               <int> 105, 98, 119, 123, 109, 103, 120, 10…

NBA player box scores (2002-2024) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  nba_player_box <- hoopR::load_nba_player_box(2021:hoopR::most_recent_nba_season())
})
tictoc::toc()
## 4.152 sec elapsed
glue::glue("{nrow(nba_player_box)} rows of NBA player boxscore data from {length(unique(nba_player_box$game_id))} games.")
## 105741 rows of NBA player boxscore data from 4048 games.
dplyr::glimpse(nba_player_box)
## Rows: 105,741
## Columns: 57
## $ game_id                           <int> 401344140, 401344140, 401344140, 401…
## $ season                            <int> 2021, 2021, 2021, 2021, 2021, 2021, …
## $ season_type                       <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, …
## $ game_date                         <date> 2021-07-20, 2021-07-20, 2021-07-20,…
## $ game_date_time                    <dttm> 2021-07-20 21:00:00, 2021-07-20 21:…
## $ athlete_id                        <int> 6581, 3147657, 4278129, 2779, 313619…
## $ athlete_display_name              <chr> "Jae Crowder", "Mikal Bridges", "Dea…
## $ team_id                           <int> 21, 21, 21, 21, 21, 21, 21, 21, 21, …
## $ team_name                         <chr> "Suns", "Suns", "Suns", "Suns", "Sun…
## $ team_location                     <chr> "Phoenix", "Phoenix", "Phoenix", "Ph…
## $ team_short_display_name           <chr> "Suns", "Suns", "Suns", "Suns", "Sun…
## $ minutes                           <dbl> 41, 39, 36, 39, 46, 11, 1, 16, 10, N…
## $ field_goals_made                  <int> 4, 3, 4, 11, 8, 3, 0, 1, 4, NA, NA, …
## $ field_goals_attempted             <int> 11, 7, 12, 19, 22, 4, 0, 5, 6, NA, N…
## $ three_point_field_goals_made      <int> 2, 0, 0, 1, 0, 0, 0, 1, 2, NA, NA, N…
## $ three_point_field_goals_attempted <int> 9, 1, 0, 2, 7, 0, 0, 4, 2, NA, NA, N…
## $ free_throws_made                  <int> 5, 1, 4, 3, 3, 0, 0, 0, 0, NA, NA, N…
## $ free_throws_attempted             <int> 5, 2, 5, 4, 3, 0, 0, 0, 0, NA, NA, N…
## $ offensive_rebounds                <int> 2, 1, 1, 1, 0, 1, 0, 0, 0, NA, NA, N…
## $ defensive_rebounds                <int> 11, 5, 5, 1, 3, 1, 0, 3, 2, NA, NA, …
## $ rebounds                          <int> 13, 6, 6, 2, 3, 2, 0, 3, 2, NA, NA, …
## $ assists                           <int> 0, 2, 1, 5, 5, 1, 0, 0, 0, NA, NA, N…
## $ steals                            <int> 4, 2, 2, 1, 0, 1, 0, 1, 0, NA, NA, N…
## $ blocks                            <int> 1, 0, 2, 0, 0, 0, 0, 1, 0, NA, NA, N…
## $ turnovers                         <int> 2, 0, 2, 3, 6, 0, 0, 0, 1, NA, NA, N…
## $ fouls                             <int> 3, 4, 5, 5, 4, 0, 0, 0, 0, NA, NA, N…
## $ plus_minus                        <chr> "+4", "-18", "-7", "-8", "-15", "0",…
## $ points                            <int> 15, 7, 12, 26, 19, 6, 0, 3, 10, NA, …
## $ starter                           <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,…
## $ ejected                           <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ did_not_play                      <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ reason                            <chr> "COACH'S DECISION", "COACH'S DECISIO…
## $ active                            <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,…
## $ athlete_jersey                    <chr> "99", "1", "22", "3", "1", "33", "0"…
## $ athlete_short_name                <chr> "J. Crowder", "M. Bridges", "D. Ayto…
## $ athlete_headshot_href             <chr> "https://a.espncdn.com/i/headshots/n…
## $ athlete_position_name             <chr> "Power Forward", "Small Forward", "C…
## $ athlete_position_abbreviation     <chr> "PF", "SF", "C", "PG", "SG", "PF", "…
## $ team_display_name                 <chr> "Phoenix Suns", "Phoenix Suns", "Pho…
## $ team_uid                          <chr> "s:40~l:46~t:21", "s:40~l:46~t:21", …
## $ team_slug                         <chr> "phoenix-suns", "phoenix-suns", "pho…
## $ team_logo                         <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ team_abbreviation                 <chr> "PHX", "PHX", "PHX", "PHX", "PHX", "…
## $ team_color                        <chr> "23006a", "23006a", "23006a", "23006…
## $ team_alternate_color              <chr> "f1f2f3", "f1f2f3", "f1f2f3", "f1f2f…
## $ home_away                         <chr> "away", "away", "away", "away", "awa…
## $ team_winner                       <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ team_score                        <int> 98, 98, 98, 98, 98, 98, 98, 98, 98, …
## $ opponent_team_id                  <int> 15, 15, 15, 15, 15, 15, 15, 15, 15, …
## $ opponent_team_name                <chr> "Bucks", "Bucks", "Bucks", "Bucks", …
## $ opponent_team_location            <chr> "Milwaukee", "Milwaukee", "Milwaukee…
## $ opponent_team_display_name        <chr> "Milwaukee Bucks", "Milwaukee Bucks"…
## $ opponent_team_abbreviation        <chr> "MIL", "MIL", "MIL", "MIL", "MIL", "…
## $ opponent_team_logo                <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ opponent_team_color               <chr> "003813", "003813", "003813", "00381…
## $ opponent_team_alternate_color     <chr> "f0ebd2", "f0ebd2", "f0ebd2", "f0ebd…
## $ opponent_team_score               <int> 105, 105, 105, 105, 105, 105, 105, 1…

Men’s college basketball play-by-plays (2006-2024) ~ 120-180 seconds

tictoc::tic()
progressr::with_progress({
  mbb_pbp <- hoopR::load_mbb_pbp(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()
## 33.509 sec elapsed
glue::glue("{nrow(mbb_pbp)} rows of men's college basketball play-by-play data from {length(unique(mbb_pbp$game_id))} games.")
## 5521939 rows of men's college basketball play-by-play data from 17179 games.
dplyr::glimpse(mbb_pbp)
## Rows: 5,521,939
## Columns: 67
## $ id                              <dbl> 4.013109e+17, 4.013109e+17, 4.013109e+…
## $ sequence_number                 <chr> "101799901", "101806001", "101806002",…
## $ type_id                         <int> 615, 558, 586, 558, 586, 558, 558, 587…
## $ type_text                       <chr> "Jumpball", "JumpShot", "Offensive Reb…
## $ text                            <chr> "Jump Ball won by Baylor", "Mark Vital…
## $ away_score                      <int> 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 4, 4, 4,…
## $ home_score                      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ period_number                   <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ period_display_value            <chr> "1st Half", "1st Half", "1st Half", "1…
## $ clock_display_value             <chr> "20:00", "19:39", "19:39", "19:36", "1…
## $ scoring_play                    <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, TRU…
## $ score_value                     <int> 0, 2, 0, 2, 0, 2, 3, 0, 2, 0, 2, 0, 0,…
## $ team_id                         <int> 239, 239, 239, 239, 239, 239, 2250, 23…
## $ shooting_play                   <lgl> FALSE, TRUE, FALSE, TRUE, FALSE, TRUE,…
## $ coordinate_x_raw                <dbl> 25, 28, 25, 25, 25, 35, 5, 25, 31, 25,…
## $ coordinate_y_raw                <dbl> 0, 6, 0, 5, 0, 14, 16, 0, 15, 0, 1, 0,…
## $ season                          <int> 2021, 2021, 2021, 2021, 2021, 2021, 20…
## $ season_type                     <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,…
## $ away_team_id                    <int> 239, 239, 239, 239, 239, 239, 239, 239…
## $ away_team_name                  <chr> "Baylor", "Baylor", "Baylor", "Baylor"…
## $ away_team_mascot                <chr> "Bears", "Bears", "Bears", "Bears", "B…
## $ away_team_abbrev                <chr> "BAY", "BAY", "BAY", "BAY", "BAY", "BA…
## $ away_team_name_alt              <chr> "Baylor", "Baylor", "Baylor", "Baylor"…
## $ home_team_id                    <int> 2250, 2250, 2250, 2250, 2250, 2250, 22…
## $ home_team_name                  <chr> "Gonzaga", "Gonzaga", "Gonzaga", "Gonz…
## $ home_team_mascot                <chr> "Bulldogs", "Bulldogs", "Bulldogs", "B…
## $ home_team_abbrev                <chr> "GONZ", "GONZ", "GONZ", "GONZ", "GONZ"…
## $ home_team_name_alt              <chr> "Gonzaga", "Gonzaga", "Gonzaga", "Gonz…
## $ home_team_spread                <dbl> 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5…
## $ game_spread                     <dbl> -4.5, -4.5, -4.5, -4.5, -4.5, -4.5, -4…
## $ home_favorite                   <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…
## $ game_spread_available           <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…
## $ game_id                         <int> 401310865, 401310865, 401310865, 40131…
## $ qtr                             <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ time                            <chr> "20:00", "19:39", "19:39", "19:36", "1…
## $ clock_minutes                   <chr> "20", "19", "19", "19", "19", "19", "1…
## $ clock_seconds                   <chr> "00", "39", "39", "36", "36", "27", "0…
## $ half                            <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ game_half                       <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ lead_qtr                        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ lead_game_half                  <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
## $ start_quarter_seconds_remaining <int> 1200, 1179, 1179, 1176, 1176, 1167, 11…
## $ start_half_seconds_remaining    <int> 1800, 1779, 1779, 1776, 1776, 1767, 17…
## $ start_game_seconds_remaining    <int> 3000, 2979, 2979, 2976, 2976, 2967, 29…
## $ game_play_number                <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,…
## $ end_quarter_seconds_remaining   <int> 600, 1200, 1179, 1179, 1176, 1176, 116…
## $ end_half_seconds_remaining      <int> 1200, 1800, 1779, 1779, 1776, 1776, 17…
## $ end_game_seconds_remaining      <int> 2400, 3000, 2979, 2979, 2976, 2976, 29…
## $ period                          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ athlete_id_1                    <int> NA, 4066292, 4066292, 4066292, 4066292…
## $ athlete_id_2                    <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lag_qtr                         <int> NA, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ lag_game_half                   <chr> NA, "1", "1", "1", "1", "1", "1", "1",…
## $ coordinate_x                    <dbl> -41.75, -35.75, -41.75, -36.75, -41.75…
## $ coordinate_y                    <dbl> 0, 3, 0, 0, 0, 10, 20, 0, 6, 0, -2, 0,…
## $ game_date                       <date> 2021-04-05, 2021-04-05, 2021-04-05, 2…
## $ game_date_time                  <dttm> 2021-04-05 21:20:00, 2021-04-05 21:20…
## $ wallclock                       <chr> "2021-04-06T01:22:23Z", "2021-04-06T01…
## $ home_timeout_called             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ away_timeout_called             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lead_period                     <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lead_half                       <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ start_period_seconds_remaining  <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ end_period_seconds_remaining    <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lag_period                      <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ lag_half                        <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ media_id                        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

Men’s college basketball team box scores (2003-2024) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  mbb_team_box <- hoopR::load_mbb_team_box(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()
## 3.269 sec elapsed
glue::glue("{nrow(mbb_team_box)} rows of men's college basketball team boxscore data from {length(unique(mbb_team_box$game_id))} games.")
## 35474 rows of men's college basketball team boxscore data from 17737 games.
dplyr::glimpse(mbb_team_box)
## Rows: 35,474
## Columns: 54
## $ game_id                           <int> 401310865, 401310865, 401310867, 401…
## $ season                            <int> 2021, 2021, 2021, 2021, 2021, 2021, …
## $ season_type                       <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, …
## $ game_date                         <date> 2021-04-05, 2021-04-05, 2021-04-03,…
## $ game_date_time                    <dttm> 2021-04-05 21:20:00, 2021-04-05 21:…
## $ team_id                           <int> 239, 2250, 26, 2250, 248, 239, 26, 1…
## $ team_uid                          <chr> "s:40~l:41~t:239", "s:40~l:41~t:2250…
## $ team_slug                         <chr> "baylor-bears", "gonzaga-bulldogs", …
## $ team_location                     <chr> "Baylor", "Gonzaga", "UCLA", "Gonzag…
## $ team_name                         <chr> "Bears", "Bulldogs", "Bruins", "Bull…
## $ team_abbreviation                 <chr> "BAY", "GONZ", "UCLA", "GONZ", "HOU"…
## $ team_display_name                 <chr> "Baylor Bears", "Gonzaga Bulldogs", …
## $ team_short_display_name           <chr> "Baylor", "Gonzaga", "UCLA", "Gonzag…
## $ team_color                        <chr> "154734", "041e42", "2774ae", "041e4…
## $ team_alternate_color              <chr> "ffb81c", "c8102e", "f2a900", "c8102…
## $ team_logo                         <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ team_home_away                    <chr> "away", "home", "away", "home", "awa…
## $ team_score                        <int> 86, 70, 90, 93, 59, 78, 51, 49, 66, …
## $ team_winner                       <lgl> TRUE, FALSE, FALSE, TRUE, FALSE, TRU…
## $ assists                           <int> 18, 16, 21, 26, 10, 23, 12, 12, 9, 2…
## $ blocks                            <int> 5, 3, 1, 3, 5, 0, 2, 3, 0, 3, 5, 5, …
## $ defensive_rebounds                <int> 22, 17, 25, 20, 14, 20, 21, 27, 21, …
## $ field_goal_pct                    <dbl> 44.8, 51.0, 57.6, 58.7, 38.2, 52.7, …
## $ field_goals_made                  <int> 30, 25, 34, 37, 21, 29, 21, 20, 24, …
## $ field_goals_attempted             <int> 67, 49, 59, 63, 55, 55, 54, 51, 62, …
## $ flagrant_fouls                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ fouls                             <int> 19, 17, 16, 16, 10, 18, 14, 11, 13, …
## $ free_throw_pct                    <dbl> 88.9, 71.4, 66.7, 60.0, 68.8, 69.2, …
## $ free_throws_made                  <int> 16, 15, 14, 12, 11, 9, 6, 6, 14, 12,…
## $ free_throws_attempted             <int> 18, 21, 21, 20, 16, 13, 7, 11, 19, 1…
## $ largest_lead                      <chr> "20", "0", "6", "7", "3", "25", "9",…
## $ offensive_rebounds                <int> 16, 5, 7, 6, 14, 13, 7, 11, 8, 12, 1…
## $ steals                            <int> 8, 4, 4, 8, 4, 6, 5, 5, 7, 6, 5, 9, …
## $ team_turnovers                    <int> 2, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, …
## $ technical_fouls                   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ three_point_field_goal_pct        <dbl> 43.5, 29.4, 47.1, 33.3, 31.6, 45.8, …
## $ three_point_field_goals_made      <int> 10, 5, 8, 7, 6, 11, 3, 3, 4, 7, 3, 8…
## $ three_point_field_goals_attempted <int> 23, 17, 17, 21, 19, 24, 13, 11, 15, …
## $ total_rebounds                    <int> 38, 22, 32, 26, 28, 33, 28, 38, 29, …
## $ total_technical_fouls             <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ total_turnovers                   <int> 9, 14, 10, 10, 11, 9, 8, 14, 10, 9, …
## $ turnovers                         <int> 9, 14, 10, 10, 11, 9, 8, 14, 10, 9, …
## $ opponent_team_id                  <int> 2250, 239, 2250, 26, 239, 248, 130, …
## $ opponent_team_uid                 <chr> "s:40~l:41~t:2250", "s:40~l:41~t:239…
## $ opponent_team_slug                <chr> "gonzaga-bulldogs", "baylor-bears", …
## $ opponent_team_location            <chr> "Gonzaga", "Baylor", "Gonzaga", "UCL…
## $ opponent_team_name                <chr> "Bulldogs", "Bears", "Bulldogs", "Br…
## $ opponent_team_abbreviation        <chr> "GONZ", "BAY", "GONZ", "UCLA", "BAY"…
## $ opponent_team_display_name        <chr> "Gonzaga Bulldogs", "Baylor Bears", …
## $ opponent_team_short_display_name  <chr> "Gonzaga", "Baylor", "Gonzaga", "UCL…
## $ opponent_team_color               <chr> "041e42", "154734", "041e42", "2774a…
## $ opponent_team_alternate_color     <chr> "c8102e", "ffb81c", "c8102e", "f2a90…
## $ opponent_team_logo                <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ opponent_team_score               <int> 70, 86, 93, 90, 78, 59, 49, 51, 85, …

Men’s college basketball player box scores (2003-2024) ~ 5-30 seconds

tictoc::tic()
progressr::with_progress({
  mbb_player_box <- hoopR::load_mbb_player_box(2021:hoopR::most_recent_mbb_season())
})
tictoc::toc()
## 6.333 sec elapsed
glue::glue("{nrow(mbb_player_box)} rows of men's college basketball player boxscore data from {length(unique(mbb_player_box$game_id))} games.")
## 563850 rows of men's college basketball player boxscore data from 17742 games.
dplyr::glimpse(mbb_player_box)
## Rows: 563,850
## Columns: 55
## $ game_id                           <int> 401310865, 401310865, 401310865, 401…
## $ season                            <int> 2021, 2021, 2021, 2021, 2021, 2021, …
## $ season_type                       <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, …
## $ game_date                         <date> 2021-04-05, 2021-04-05, 2021-04-05,…
## $ game_date_time                    <dttm> 2021-04-05 21:20:00, 2021-04-05 21:…
## $ athlete_id                        <int> 4395692, 4395695, 4278053, 4067696, …
## $ athlete_display_name              <chr> "Flo Thamba", "Jared Butler", "Davio…
## $ team_id                           <int> 239, 239, 239, 239, 239, 239, 239, 2…
## $ team_name                         <chr> "Bears", "Bears", "Bears", "Bears", …
## $ team_location                     <chr> "Baylor", "Baylor", "Baylor", "Baylo…
## $ team_short_display_name           <chr> "Baylor", "Baylor", "Baylor", "Baylo…
## $ minutes                           <dbl> 16, 31, 36, 31, 27, 1, 16, 16, 1, 1,…
## $ field_goals_made                  <int> 0, 6, 6, 8, 3, 0, 3, 1, 0, 0, 3, 0, …
## $ field_goals_attempted             <int> 3, 14, 15, 15, 7, 0, 4, 2, 0, 1, 6, …
## $ three_point_field_goals_made      <int> 0, 4, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, …
## $ three_point_field_goals_attempted <int> 0, 9, 4, 3, 1, 0, 0, 1, 0, 1, 4, 0, …
## $ free_throws_made                  <int> 3, 6, 2, 1, 0, 0, 0, 0, 0, 0, 4, 0, …
## $ free_throws_attempted             <int> 4, 6, 2, 2, 0, 0, 0, 0, 0, 0, 4, 0, …
## $ offensive_rebounds                <int> 3, 0, 1, 0, 8, 0, 1, 0, 0, 0, 1, 0, …
## $ defensive_rebounds                <int> 3, 3, 5, 2, 3, 0, 1, 2, 0, 0, 1, 0, …
## $ rebounds                          <int> 6, 3, 6, 2, 11, 0, 2, 2, 0, 0, 2, 0,…
## $ assists                           <int> 0, 7, 5, 0, 2, 0, 1, 1, 0, 0, 2, 0, …
## $ steals                            <int> 0, 0, 1, 0, 2, 0, 2, 1, 0, 0, 1, 0, …
## $ blocks                            <int> 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, …
## $ turnovers                         <int> 1, 0, 3, 1, 0, 0, 0, 1, 0, 0, 1, 0, …
## $ fouls                             <int> 5, 3, 1, 0, 3, 0, 4, 1, 0, 0, 2, 0, …
## $ points                            <int> 3, 22, 15, 19, 6, 0, 6, 2, 0, 0, 13,…
## $ starter                           <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,…
## $ ejected                           <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ did_not_play                      <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ active                            <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, F…
## $ athlete_jersey                    <chr> "0", "12", "45", "31", "11", "32", "…
## $ athlete_short_name                <chr> "F. Thamba", "J. Butler", "D. Mitche…
## $ athlete_headshot_href             <chr> "https://a.espncdn.com/i/headshots/m…
## $ athlete_position_name             <chr> "Forward", "Guard", "Guard", "Guard"…
## $ athlete_position_abbreviation     <chr> "F", "G", "G", "G", "G", "F", "F", "…
## $ team_display_name                 <chr> "Baylor Bears", "Baylor Bears", "Bay…
## $ team_uid                          <chr> "s:40~l:41~t:239", "s:40~l:41~t:239"…
## $ team_slug                         <chr> "baylor-bears", "baylor-bears", "bay…
## $ team_logo                         <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ team_abbreviation                 <chr> "BAY", "BAY", "BAY", "BAY", "BAY", "…
## $ team_color                        <chr> "154734", "154734", "154734", "15473…
## $ team_alternate_color              <chr> "ffb81c", "ffb81c", "ffb81c", "ffb81…
## $ home_away                         <chr> "away", "away", "away", "away", "awa…
## $ team_winner                       <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, …
## $ team_score                        <int> 86, 86, 86, 86, 86, 86, 86, 86, 86, …
## $ opponent_team_id                  <int> 2250, 2250, 2250, 2250, 2250, 2250, …
## $ opponent_team_name                <chr> "Bulldogs", "Bulldogs", "Bulldogs", …
## $ opponent_team_location            <chr> "Gonzaga", "Gonzaga", "Gonzaga", "Go…
## $ opponent_team_display_name        <chr> "Gonzaga Bulldogs", "Gonzaga Bulldog…
## $ opponent_team_abbreviation        <chr> "GONZ", "GONZ", "GONZ", "GONZ", "GON…
## $ opponent_team_logo                <chr> "https://a.espncdn.com/i/teamlogos/n…
## $ opponent_team_color               <chr> "041e42", "041e42", "041e42", "041e4…
## $ opponent_team_alternate_color     <chr> "c8102e", "c8102e", "c8102e", "c8102…
## $ opponent_team_score               <int> 70, 70, 70, 70, 70, 70, 70, 70, 70, …

Our Authors

Our Contributors (they’re awesome)