knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
Sys.setenv(TZ="Europe/London")

bballR: Scrape basketball data from basketball-reference.com in R

The bballR package uses tidyverse packages to efficiently scrape data from basketball-reference and return it in the tidy data format.

Installation

devtools::install_github("bobbyingram/bballR")

Usage

Players

To scrape high-level player information for players in the basketball-reference player database use

library(bballR)
players <- scrape_all_players()
dplyr::glimpse(players)

Teams

To scrape high-level information for teams in the the basketball-reference team database use

all_teams <- scrape_teams()
active_teams <- scrape_teams(status = "active")
defunct_teams <- scrape_teams(status = "defunct")
dplyr::glimpse(all_teams)

Seasons

To scrape summary player performance data for an individual season use

season <- 2017
per_game_2017 <- scrape_season_per_game(season)
per_100_2017 <- scrape_season_per_100_poss(season)
per_36_2017 <- scrape_season_per_36_minute(season)
adv_2017 <- scrape_season_advanced(season)
totals_2017 <- scrape_season_totals(season)
dplyr::glimpse(per_game_2017)

Game Logs

To scrape an individual players regular season game logs from a single season you need to know use unique player Id from the players lookup:

player <- "Dwyane Wade"
wade <- dplyr::filter(players, Player == player)
wade_logs <- scrape_game_logs(wade$PlayerId, season)
dplyr::glimpse(wade_logs)


TambourineMan88/bballR documentation built on Dec. 11, 2019, 7:23 p.m.