full.game.database: Create a shell database for NHL games from 2002 to 2013, then...

Description Usage Arguments Details Value Author(s) Examples

Description

Creates a shell database for NHL games from 2002 to 2013, unfilled with game information. Uses this to collect and scrape NHL data, but not process them immediately.

Usage

1
2
3
4
5
6
7
  full.game.database()
  download.single.game (season="20122013",
                        gcode="20001",
                        rdata.folder="nhlr-data",
                        verbose=TRUE)
  download.games       (games=full.game.database(),
                        rdata.folder="nhlr-data")

Arguments

season

A character string for the two years specifying an NHL season.

gcode

The five-digit ID number for a particular NHL game.

rdata.folder

The location within the current directory to which to save the downloaded files. Will be created if it does not exist.

verbose

Report additional messages.

games

A game database, such as the one produced by full.game.database().

Details

full.game.database() gives ID numbers for all regular-season and playoff games played between 2002 and 2013, with indicators for whether any particular game is known to be unavailable.

download.single.game() retrieves the relevant files for a single game from NHL.com.

download.games() retrieves the files for all games in the table.

Value

full.game.database: a data frame with columns including season, session (Regular or Playoffs), game number/gcode (which game in the season?). Placeholders for teams, score and date of game are included to be filled in later. “valid” indicates whether a full record of the game is available for download.

download.single.game: returns a single Boolean value indicating if no errors were recorded during the download. Saves the game to disk, particularly the PL, ES, SCH and SCV files, along with JSON data for x-y events.

download.games: returns the input game database with “valid” changed to FALSE for any failed downloads.

Author(s)

A.C. Thomas <act@acthomas.ca>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  #Select a part of the history.
  game.table <- full.game.database()[201:220,]

  #Download one game.
  download.single.game(game.table$season[1], game.table$gcode[1])

  #Download all games.

## Not run: 
  game.table.updated <- download.games (games=game.table)

## End(Not run)

bensoltoff/nhlscrapr documentation built on May 12, 2019, 2:08 p.m.