Learn R Programming

nflscrapR (version 1.8.3)

scrape_game_ids: Scrape game ids for a given NFL season (either pre, regular, or post-season)

Description

This function returns all available game ids for a given season, with an option specifying which type of game ids to return (either the pre, regular, or post season) as well as the weeks considered.

Usage

scrape_game_ids(season, type = "reg", weeks = NULL, teams = NULL)

Arguments

season

Numeric 4-digit year associated with an NFL season

type

String indicating the type of game ids to find, must either be "pre", "reg", or "post" (default is "reg").

weeks

Numeric vector indicating which weeks of preseason (0 to 4 except for 2011 season without Hall of Fame game) or regular season games (1 to 17) to grab (default value of NULL corresponds to selecting all available weeks).

teams

String vector indicating which teams (based on the abbreviation) the function should grab game info for (default value of NULL corresponds to selecting all available teams).

Value

Data frame with columns containing the season type, game_id, week number (if pre or regular season), the year of the season, home team, away team, a variable indicating the state of the game (POST is over, PRE is before or during), game's url, and the home and away team scores if the game is over.

Examples

Run this code
# NOT RUN {
# Scraping all game ids from 2017 regular season:
scrape_game_ids(2017) 
# }

Run the code above in your browser using DataLab