tidy_games_events: Get a tidy dataset of NHL games events

View source: R/tidy_games_events.R

tidy_games_eventsR Documentation

Get a tidy dataset of NHL games events

Description

The function tidy_games_events() is meant to be a user-friendly way of connecting events of different types in selected NHL games.

Usage

tidy_games_events(
  games_id,
  time_elapsed = 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 events 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.

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 events of the 2021-01-13 MTL @ TOR game
tidy_games_events(2020020003L)

# Get events of both the 2021-01-13 MTL @ TOR and 2021-01-14 BOS @ NJD games with time remaining
# instead of time elapsed, and keeping the IDs
tidy_games_events(
  games_id = c(2020020003L, 2020020007L),
  time_elapsed = FALSE,
  keep_id = TRUE
)


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