acquire: Acquire player tracking data from http://stats.nba.com/

Description Usage Arguments Examples

Description

All the arguments to this function

Usage

1
2
3
4
5
acquire(type = "shot", PlayerID = "2544", DateFrom = "", DateTo = "",
  GameSegment = "", LastNGames = "0", LeagueID = "00", Location = "",
  Month = "0", OpponentTeamID = "0", Outcome = "", Period = "0",
  Season = "2013-14", SeasonSegment = "", SeasonType = "Regular+Season",
  TeamID = "0", VsConference = "", VsDivision = "", PerMode = "PerGame")

Arguments

type

Required type of tracking data. Eligible values are 'shot', 'rebound', 'pass', 'shotdefend', 'reb', 'shots'. The most useful/interesting are 'shot' and 'rebound'.

PlayerID

Required player ID. See data(players)

DateFrom

Optionally set date to begin acquiring data (in the format 'YYYY/MM/DD')

DateTo

Optionally set date to stop acquiring data (in the format 'YYYY/MM/DD')

GameSegment

Optionally filter by 'First+Half', Second+Half', or 'Overtime'.

LastNGames

Optionally filter by the last 'n' number of games.

LeagueID

Character vector with any combination of '00', '10', and/or '20'. These codes stand for NBA, WNBA and D-League, respectively.

Location

Optionally filter by 'Home' or 'Road' games?

Month

Optionally filter by Month (use '1' for Oct, '2' for Nov, etc.)

OpponentTeamID

Optionally filter by opposing team

Outcome

Optionally filter by wins (use 'W') or losses (use 'L')

Period

Optionally filter by quarter/OT (use '1' for 1st Quarter, '2' for 2nd, etc.)

Season

Required filter on season year

SeasonSegment

Optionally filter by 'Pre All-Star' or 'Post All-Star'

SeasonType

Required filter on either 'Regular Season' or 'Playoffs'

TeamID
VsConference
VsDivision
PerGame

Aggregate 'PerGame' or 'Totals'. Only relevant for "dashboards"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
# Defaults to Lebron's shots from the 2013-14 regular season
shots <- acquire()
# Lebron's rebounds from the 2013-14 regular season
rebounds <- acquire("rebound")
# The rest of these data types are "dashboards"
# That is, they show summary statistics that will change over
# the season. For this reason, you probably don't want to
# store these in a database.
pass_dash <- acquire("pass")
defense_dash <- acquire("shotdefend")
reb_dash <- acquire("reb")
shot_dash <- acquire("shots")

# All the shots for the 2013-14 season!
ids <- players[, 'PlayerID']
lshots <- lapply(ids, function(x) acquire(PlayerID = x))
allshots <- do.call("rbind", lshots)

# All the rebounds for the 2013-14 season!
lrebounds <- lapply(ids, function(x)
                 acquire(type = "rebound", PlayerID = x))
allrebs <- do.call("rbind", lrebounds)

## End(Not run)

cpsievert/bbscrapeR documentation built on May 13, 2019, 10:54 p.m.