Motivation

The gameday package provides a convenient way to extract simple information on NHL teams without using your internet browser. Sometimes we get distracted by extraneous information on the web and our attention is diverted. Using the functions in gameday can prevent this from happening!

Usage

First we need to load the package.

library(gameday)

gday(team, date)

We can use this to check whether a specified team plays on a specified date. For example, a simple usage of this:

# Checks whether the Canucks play today
gday()

# Checks whether the Bruins play tomorrow
gday("bruins", Sys.Date() + 1)

scores(date)

We use this to lookup all the final scores on a particular date. For instance, the data.frame output for the games on Remembrance Day are:

# Lookup final scores on Remembrance Day
scores("2014-11-11")

There is more functionality we can utilize with scores(). We can look up all the winning teams of a certain hockey date. For this we'll employ dplyr.

suppressPackageStartupMessages(library(dplyr))

# All winning teams on a particular date
score_data <- scores("2014-11-11")
score_data %>%
    mutate(winner = ifelse(home_score > away_score, as.character(home), as.character(away))) %>%
    select(winner)

Comparing the winners with the raw score_data, we see that indeed only the winning teams are shown.



dchiu911/gameday documentation built on May 15, 2019, 1:48 a.m.