nhl_make_seasons: Make a vector of seasons consumable by the API

Description Usage Arguments Value Examples

View source: R/nhl_utils.R

Description

The NHL API wants seasons defined in format "YYYYZZZZ" where ZZZZ = YYYY + 1. This is a helper to take a vector of years in "YYYY" format and create a vector of such seasons to be used with the API.

Usage

1
nhl_make_seasons(seasons = 1950:2019)

Arguments

seasons

numeric(), integer() or character(), vector of starting years of desired seasons in YYYY format, e.g. 1995 or "1995" for season 1995-1996. Accepts vectors such as c(1995:2000, 2010) to generate multiple seasons.

Alternatively, also accepts character() with seasons in the format "YYYYZZZZ", where ZZZZ = YYYY + 1, e.g. "19951996". This is the format that ultimately gets sent to the NHL API.

Some API endpoints, notably seasons exposed via nhl_seasons() also allow the value "current" to passed. This value will be returned unchanged.

Value

character(), vector of seasons suited for the NHL API.

Examples

1
2
3
4
  nhlapi:::nhl_make_seasons()
  nhlapi:::nhl_make_seasons(1995:2000)
  nhlapi:::nhl_make_seasons(c(1995, 2015))
  nhlapi:::nhl_make_seasons(c("1995", "2015"))

nhlapi documentation built on Feb. 20, 2021, 9:06 a.m.