Skip to contents

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

Usage

load_phf_pbp(
  seasons = most_recent_phf_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years associated with given PHF seasons. (Min: 2011)

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_phf_db()).

dbConnection

A DBIConnection object, as returned by DBI::dbConnect()

tablename

The name of the play by play data table within the database

Value

A dataframe

Examples

# \donttest{
  try(load_phf_pbp(2021))
#> ── PHF Play-by-Play Information from fastRhockey data repository ───────────────
#>  Data updated: 2023-01-04 07:36:01 UTC
#> # A tibble: 3,003 × 79
#>    play_type team  time  play_…¹ perio…² game_id home_…³ home_…⁴ home_…⁵ home_…⁶
#>    <chr>     <chr> <chr> <chr>     <int>   <int> <chr>   <chr>   <chr>   <chr>  
#>  1 Goalie    Metr… 00:00 Starti…       1  368723 Metrop… Metrop… Rivete… MET    
#>  2 Goalie    Toro… 00:00 Starti…       1  368723 Metrop… Metrop… Rivete… MET    
#>  3 Faceoff   Toro… 00:01 #27 Sh…       1  368723 Metrop… Metrop… Rivete… MET    
#>  4 Shot BLK  Metr… 01:35 #26 Ki…       1  368723 Metrop… Metrop… Rivete… MET    
#>  5 Goal      Metr… 01:43 #5 Lei…       1  368723 Metrop… Metrop… Rivete… MET    
#>  6 Shot      Metr… 02:01 #22 Al…       1  368723 Metrop… Metrop… Rivete… MET    
#>  7 Shot      Metr… 02:05 #3 The…       1  368723 Metrop… Metrop… Rivete… MET    
#>  8 Penalty   Toro… 03:01 #25 Em…       1  368723 Metrop… Metrop… Rivete… MET    
#>  9 Faceoff   Metr… 03:01 #8 Kel…       1  368723 Metrop… Metrop… Rivete… MET    
#> 10 Faceoff   Metr… 03:42 #4 Emi…       1  368723 Metrop… Metrop… Rivete… MET    
#> # … with 2,993 more rows, 69 more variables: home_score_total <int>,
#> #   away_team <chr>, away_location <chr>, away_nickname <chr>,
#> #   away_abbreviation <chr>, away_score_total <int>, home_goalie <chr>,
#> #   home_goalie_jersey <chr>, goalie_change <chr>, penalty <int>,
#> #   on_ice_situation <chr>, score <chr>, minute_start <int>,
#> #   second_start <int>, clock <chr>, leader <chr>, away_goals <chr>,
#> #   home_goals <chr>, sec_from_start <int>, power_play_seconds <int>, …
# }