tidy_games_faceoffs: Get a tidy dataset of NHL games faceoffs

View source: R/tidy_games_faceoffs.R

tidy_games_faceoffsR Documentation

Get a tidy dataset of NHL games faceoffs

Description

The function tidy_games_faceoffs() is meant to be a user-friendly way of getting data about faceoffs in selected NHL games.

Usage

tidy_games_faceoffs(
  games_id,
  time_elapsed = TRUE,
  standardized_coordinates = TRUE,
  keep_id = FALSE,
  return_datatable = getOption("tidynhl.data.table", TRUE)
)

Arguments

games_id

Integer vector indicating the NHL ID of selected games for which the faceoff data will be returned. The required format is 'xxxxyyzzzz' where

  • 'xxxx' is the first 4 digits of a valid NHL season ID,

  • 'yy' is one of "02" (regular) or "03" (playoffs),

  • 'zzzz' is a 4-digit number attributed to a single game.

time_elapsed

(optional) Logical indicating if the time sould be indicated as elapsed (TRUE) or remaining (FALSE). Default to TRUE.

standardized_coordinates

(optional) Logical indicating if the ice coordinates should be standardized (away team zone negative on the x-axis) or kept as is. Default to TRUE.

keep_id

(optional) Logical indicating if the IDs of different dimensions should be returned. However, note that game_id will always be returned. Default to FALSE.

return_datatable

(optional) Logical indicating whether or not a data.table should be returned. Default can be set globally with options("tidynhl.data.table").

Examples

# Allowing large outputs for the pkgdown website
options(width = 1000L)

# Get faceoffs data of the 2021-01-13 MTL @ TOR game
tidy_games_faceoffs(2020020003L)

# Get faceoffs data of both the 2021-01-13 MTL @ TOR and 2021-01-14 BOS @ NJD games with time
# remaining instead of time elapsed, as is coordinates instead of normalized, and keeping the IDs
tidy_games_faceoffs(
  games_id = c(2020020003L, 2020020007L),
  time_elapsed = FALSE,
  standardized_coordinates = FALSE,
  keep_id = TRUE
)


jplecavalier/tidynhl documentation built on July 28, 2024, 3:48 a.m.