The goal of tidynhl is to make it easy for users to extract NHL data in a tidy format. In this sense, the word tidy refers to a state in which the data is already neat enough to begin analyses right away, without having to clean anything or make any significant transformations.

This package was at first a project that I created to answer personal needs. This explains, in part, the dependency to the data.table package (I myself am a massive user). Even if I could get rid of the dependency without significant efforts, I decided to stick to it, hoping to influence as many users as possible to at least give it a try. This being said, it is totally possible to use the package without using data.table to handle the resulting data. The native behavior of tidynhl is to return tidy datasets in data.table objects, but one could easily set options("tidynhl.data.table") to FALSE to get standard data.frame objects.

First of all, let’s attach tidynhl and data.table to begin our overview of the package with a simple use case, analyzing the NHL careers of Vincent Lecavalier and Martin St. Louis, long date teammates and major leaders in the 2000s for the Tampa Bay Lightning.

The package contains two different families of functions:

  • The functions prefixed by tidy_ will return a tidy dataset ready to use in analyses.
  • The functions prefixed by get_ are helper functions to facilitate other tasks.

NHL Entry Drafts

Even though Lecavalier and St. Louis both had successful careers, their NHL beginnings were totally opposite. Indeed, Lecavalier was the overall first pick of the 1998 NHL Entry Draft while St. Louis was never drafted at all (even though he was available for selection in the 1993 NHL Entry Draft). First, let’s retrieve data about the 1993 and 1998 NHL Entry Drafts.

drafts <- tidy_drafts(c(1993L, 1998L))
drafts[]
#>      draft_year draft_round draft_pick draft_overall team_abbreviation       player_name amateur_league_name    amateur_team_name
#>   1:       1993           1          1             1               OTT  Alexandre Daigle               QMJHL Victoriaville Tigres
#>   2:       1993           1          2             2               HFD     Chris Pronger                 OHL   Peterborough Petes
#>   3:       1993           1          3             3               TBL     Chris Gratton                 OHL  Kingston Frontenacs
#>   4:       1993           1          4             4               ANA       Paul Kariya                NCAA          U. of Maine
#>   5:       1993           1          5             5               FLA   Rob Niedermayer                 WHL  Medicine Hat Tigers
#>  ---                                                                                                                             
#> 540:       1998           9         26           254               PIT       Matt Hussey               Conn.  Avon Old Farms H.S.
#> 541:       1998           9         27           255               STL         John Pohl               Minn.        Red Wing H.S.
#> 542:       1998           9         28           256               DET Petja Pietilainen                 WHL     Saskatoon Blades
#> 543:       1998           9         29           257               NJD         Ryan Held                 OHL    Kitchener Rangers
#> 544:       1998           9         30           258               PHI    Sergei Skrobot              Russia      Dynamo-2 Moscow

The top-5 selection the year when Lecavalier was drafted was

drafts[draft_year == 1998L & draft_overall <= 5L]
#>    draft_year draft_round draft_pick draft_overall team_abbreviation        player_name amateur_league_name   amateur_team_name
#> 1:       1998           1          1             1               TBL Vincent Lecavalier               QMJHL    Rimouski Oceanic
#> 2:       1998           1          2             2               NSH      David Legwand                 OHL    Plymouth Whalers
#> 3:       1998           1          3             3               SJS        Brad Stuart                 WHL         Regina Pats
#> 4:       1998           1          4             4               VAN        Bryan Allen                 OHL     Oshawa Generals
#> 5:       1998           1          5             5               ANA  Vitaly Vishnevski              Russia Torpedo-2 Yaroslavl

We could make fun of NHL scouts by printing five random players that have been chosen in 1993 while St. Louis was still available.

drafts[draft_year == 1993L][sample(.N, 5L)]
#>    draft_year draft_round draft_pick draft_overall team_abbreviation      player_name amateur_league_name        amateur_team_name
#> 1:       1993           8         10           192               PHI      Paul Healey                 WHL    Prince Albert Raiders
#> 2:       1993           2         13            39               NJD Brendan Morrison               BCJHL       Penticton Panthers
#> 3:       1993           8         21           203               MTL      Alan Letang                 OHL         Newmarket Royals
#> 4:       1993           5         24           128               CHI  Jonni Vauhkonen             FINLAND             Reipas Lahti
#> 5:       1993           3         15            67               FLA  Mikael Tjallden                 SEL Modo Hockey Ornskoldsvik

I will admit that Brendan Morrison was a fair choice (still far behind St. Louis in terms of NHL success), but I honestly never heard of any other.

Career overview

In order to be able to get information on Lecavalier and St. Louis, we will first need to get their personal NHL IDs.

ids <- get_players_id(c("Vincent Lecavalier", "Martin St. Louis"))
ids
#> [1] 8467329 8466378

We can now retrieve some metadata about both players using those IDs.

meta <- tidy_players_meta(ids)
meta[]
#>           player_name player_active player_roster_status player_number player_position player_position_type player_nationality player_birth_country player_birth_stateprovince player_birth_city player_birth_date player_dead player_death_date player_inches player_pounds player_hand player_rookie player_hof player_hof_year player_nhl_100 team_abbreviation
#> 1:   Martin St. Louis         FALSE                    Y            26               R                    F                CAN                  CAN                         QC             Laval        1975-06-18       FALSE              <NA>            68           180           L         FALSE       TRUE            2018          FALSE              <NA>
#> 2: Vincent Lecavalier         FALSE                    N            44               C                    F                CAN                  CAN                         QC        Ile Bizard        1980-04-21       FALSE              <NA>            76           215           L         FALSE      FALSE              NA          FALSE              <NA>

Note the 8-inches difference in height! Let’s now retrieve their NHL career statistics.

career_stats <- tidy_skaters_stats(ids)
career_stats[]
#>            player_name season_years season_type team_abbreviation skater_games skater_goals skater_assists skater_points skater_plusminus skater_pim skater_toi skater_shifts skater_gwg skater_otg skater_shots skater_blocked skater_hits skater_ev_goals skater_ev_assists skater_ev_points skater_ev_toi skater_pp_goals skater_pp_assists skater_pp_points skater_pp_toi skater_pk_goals skater_pk_assists skater_pk_points skater_pk_toi
#>  1:   Martin St. Louis      1998-99     regular               CGY           13            1              1             2               -2         10  107.30000           135          0          0           14              0           8               1                 0                1      89.08333               0                 1                1     17.333333               0                 0                0     0.8833333
#>  2:   Martin St. Louis      1999-00     regular               CGY           56            3             15            18               -5         22  822.51667          1181          1          0           73              0          47               3                14               17     646.30000               0                 0                0     39.766667               0                 1                1   136.4500000
#>  3:   Martin St. Louis      2000-01     regular               TBL           78           18             22            40               -4         12 1188.73333          1509          4          0          141              0          45              12                17               29     917.86667               3                 4                7     98.016667               3                 1                4   172.8500000
#>  4:   Martin St. Louis      2001-02     regular               TBL           53           16             19            35                4         20  989.93333          1206          2          0          105              0          32               9                16               25     773.86667               6                 2                8    157.316667               1                 1                2    58.7500000
#>  5:   Martin St. Louis      2002-03     regular               TBL           82           33             37            70               10         32 1600.45000          2026          5          0          201             13          10              18                29               47    1123.35000              12                 7               19    331.550000               3                 1                4   145.5500000
#>  6:   Martin St. Louis      2002-03    playoffs               TBL           11            7              5            12                5          0  245.80000           348          3          1           25              0          11               4                 3                7     189.78333               1                 2                3     29.350000               2                 0                2    26.6666667
#>  7:   Martin St. Louis      2003-04     regular               TBL           82           38             56            94               35         24 1687.76667          2119          7          1          212              0          34              22                31               53    1223.03333               8                22               30    332.550000               8                 3               11   132.1833333
#>  8:   Martin St. Louis      2003-04    playoffs               TBL           23            9             15            24                6         14  525.98333           699          3          2           58              0          19               5                11               16     400.11667               3                 4                7     86.816667               1                 0                1    39.0500000
#>  9:   Martin St. Louis      2005-06     regular               TBL           80           31             30            61               -3         38 1678.96667          2021          7          1          221             31          23              19                18               37    1135.85000               9                11               20    380.416667               3                 1                4   162.7000000
#> 10:   Martin St. Louis      2005-06    playoffs               TBL            5            4              0             4               -2          2  114.45000           143          1          0           15              0           4               3                 0                3      74.36667               1                 0                1     29.966667               0                 0                0    10.1166667
#> 11:   Martin St. Louis      2006-07     regular               TBL           82           43             59           102                7         28 1980.80000          2185          7          2          273             44          44              24                37               61    1441.95000              14                16               30    397.333333               5                 6               11   141.5166667
#> 12:   Martin St. Louis      2006-07    playoffs               TBL            6            3              5             8                6          8  168.65000           183          0          0           17              3           8               2                 4                6     123.96667               1                 1                2     33.050000               0                 0                0    11.6333333
#> 13:   Martin St. Louis      2007-08     regular               TBL           82           25             58            83              -23         26 1991.28333          2070          5          0          241             45          34              13                38               51    1503.53333              10                19               29    342.550000               2                 1                3   145.2000000
#> 14:   Martin St. Louis      2008-09     regular               TBL           82           30             50            80                4         14 1745.45000          2108          3          1          262             48          17              21                31               52    1224.61667               7                18               25    379.050000               2                 1                3   141.7833333
#> 15:   Martin St. Louis      2009-10     regular               TBL           82           29             65            94               -8         12 1788.35000          2137          7          2          242             40          20              21                35               56    1305.63333               7                30               37    387.500000               1                 0                1    95.2166667
#> 16:   Martin St. Louis      2010-11     regular               TBL           82           31             68            99                0         12 1720.35000          1991          7          1          254             64          37              27                31               58    1311.93333               4                37               41    370.383333               0                 0                0    38.0333333
#> 17:   Martin St. Louis      2010-11    playoffs               TBL           18           10             10            20               -8          4  381.38333           450          1          0           50             15           8               6                 3                9     305.15000               4                 7               11     73.933333               0                 0                0     2.3000000
#> 18:   Martin St. Louis      2011-12     regular               TBL           77           25             49            74               -3         16 1742.71667          1847          3          1          185             39          17              21                37               58    1419.13333               4                12               16    290.650000               0                 0                0    32.9333333
#> 19:   Martin St. Louis      2012-13     regular               TBL           48           17             43            60                0         14 1055.20000          1149          2          0          112             32          23              14                26               40     844.11667               3                17               20    173.250000               0                 0                0    37.8333333
#> 20:   Martin St. Louis      2013-14     regular               TBL           62           29             32            61               12          6 1344.81667          1612          5          1          167             22          15              20                22               42    1054.28333               9                 9               18    214.366667               0                 1                1    76.1666667
#> 21:   Martin St. Louis      2013-14     regular               NYR           19            1              7             8                1          4  351.36667           469          0          0           37             16           9               0                 4                4     279.20000               0                 3                3     54.266667               1                 0                1    17.9000000
#> 22:   Martin St. Louis      2013-14    playoffs               NYR           25            8              7            15               -5          2  481.58333           679          3          1           55             22          10               6                 3                9     357.15000               2                 4                6     90.100000               0                 0                0    34.3333333
#> 23:   Martin St. Louis      2014-15     regular               NYR           74           21             31            52               12         20 1299.65000          1691          1          0          144             37          13              16                23               39    1078.88333               5                 8               13    212.683333               0                 0                0     8.0833333
#> 24:   Martin St. Louis      2014-15    playoffs               NYR           19            1              6             7               -1          4  313.50000           449          0          0           32              9          12               0                 4                4     258.75000               1                 2                3     54.216667               0                 0                0     0.5333333
#> 25: Vincent Lecavalier      1998-99     regular               TBL           82           13             15            28              -19         23 1120.11667          1155          2          0          125              0          52              11                10               21     918.91667               2                 4                6    189.733333               0                 1                1    11.4666667
#> 26: Vincent Lecavalier      1999-00     regular               TBL           80           25             42            67              -25         43 1544.11667          1668          3          0          166              0         116              19                20               39    1114.41667               6                22               28    417.566667               0                 0                0    12.1333333
#> 27: Vincent Lecavalier      2000-01     regular               TBL           68           23             28            51              -26         66 1356.13333          1436          3          0          165              0          72              16                18               34     946.13333               7                10               17    389.300000               0                 0                0    20.7000000
#> 28: Vincent Lecavalier      2001-02     regular               TBL           76           20             17            37              -18         61 1302.85000          1516          3          2          164              0          85              15                 8               23    1052.18333               5                 9               14    241.433333               0                 0                0     9.2333333
#> 29: Vincent Lecavalier      2002-03     regular               TBL           80           33             45            78                0         39 1543.25000          1843          3          0          274             13          43              20                32               52    1134.86667              11                13               24    327.400000               2                 0                2    80.9833333
#> 30: Vincent Lecavalier      2002-03    playoffs               TBL           11            3              3             6               -2         22  248.53333           325          1          1           32              0           8               2                 1                3     199.43333               1                 2                3     35.700000               0                 0                0    13.4000000
#> 31: Vincent Lecavalier      2003-04     regular               TBL           81           32             34            66               23         52 1462.85000          1858          6          0          242              0          48              25                25               50    1136.56667               5                 9               14    282.466667               2                 0                2    43.8166667
#> 32: Vincent Lecavalier      2003-04    playoffs               TBL           23            9              7            16               -2         25  451.83333           626          0          0           76              0          33               7                 4               11     366.68333               2                 3                5     78.800000               0                 0                0     6.3500000
#> 33: Vincent Lecavalier      2005-06     regular               TBL           80           35             40            75                0         90 1610.11667          1881          7          1          309             33          78              20                20               40    1100.68333              13                19               32    414.483333               2                 1                3    94.9500000
#> 34: Vincent Lecavalier      2005-06    playoffs               TBL            5            1              3             4                0          7  111.43333           137          0          0           17              1          10               0                 2                2      72.43333               1                 1                2     28.783333               0                 0                0    10.2166667
#> 35: Vincent Lecavalier      2006-07     regular               TBL           82           52             56           108                2         44 1853.53333          2105          7          1          339             22         112              31                32               63    1340.31667              16                20               36    388.150000               5                 4                9   125.0666667
#> 36: Vincent Lecavalier      2006-07    playoffs               TBL            6            5              2             7                4         10  158.86667           183          1          0           30              1          21               4                 1                5     112.26667               1                 1                2     32.816667               0                 0                0    13.7833333
#> 37: Vincent Lecavalier      2007-08     regular               TBL           81           40             52            92              -17         89 1859.08333          2014          7          0          318             21         112              29                30               59    1394.66667              10                19               29    337.950000               1                 3                4   126.4666667
#> 38: Vincent Lecavalier      2008-09     regular               TBL           77           29             38            67               -9         54 1559.46667          1943          6          1          291             29         110              18                23               41    1120.43333              10                14               24    327.883333               1                 1                2   111.1500000
#> 39: Vincent Lecavalier      2009-10     regular               TBL           82           24             46            70              -16         63 1622.81667          2029          3          0          295             21          80              19                26               45    1234.46667               5                20               25    331.416667               0                 0                0    56.9333333
#> 40: Vincent Lecavalier      2010-11     regular               TBL           65           25             29            54               -5         43 1199.51667          1464          5          2          210             25          93              13                13               26     925.20000              12                16               28    259.266667               0                 0                0    15.0500000
#> 41: Vincent Lecavalier      2010-11    playoffs               TBL           18            6             13            19                6         16  357.50000           444          3          1           56              7          20               3                 9               12     281.13333               3                 4                7     72.350000               0                 0                0     4.0166667
#> 42: Vincent Lecavalier      2011-12     regular               TBL           64           22             27            49               -2         50 1211.60000          1407          5          1          182             31         103              17                21               38     982.26667               5                 6               11    217.633333               0                 0                0    11.7000000
#> 43: Vincent Lecavalier      2012-13     regular               TBL           39           10             22            32               -5         29  697.43333           851          0          0           86             13          74               5                18               23     570.95000               5                 4                9    119.200000               0                 0                0     7.2833333
#> 44: Vincent Lecavalier      2013-14     regular               PHI           69           20             17            37              -16         44 1048.16667          1389          3          1          132             19          77              12                12               24     876.33333               8                 5               13    169.250000               0                 0                0     2.5833333
#> 45: Vincent Lecavalier      2013-14    playoffs               PHI            7            1              1             2               -5          2   74.80000           110          0          0            9              2           4               0                 0                0      61.61667               1                 1                2     13.183333               0                 0                0     0.0000000
#> 46: Vincent Lecavalier      2014-15     regular               PHI           57            8             12            20               -7         36  720.90000           983          0          0          103             15          40               7                 9               16     610.73333               1                 3                4    109.983333               0                 0                0     0.1833333
#> 47: Vincent Lecavalier      2015-16     regular               PHI            7            0              1             1               -1          2   66.21667            99          0          0            7              1           2               0                 1                1      63.78333               0                 0                0      2.433333               0                 0                0     0.0000000
#> 48: Vincent Lecavalier      2015-16     regular               LAK           42           10              7            17                1         20  582.55000           830          0          0           60             21          60               4                 6               10     485.61667               6                 1                7     73.266667               0                 0                0    23.6666667
#> 49: Vincent Lecavalier      2015-16    playoffs               LAK            5            1              1             2                0          2   71.66667           109          0          0            8              2          11               0                 1                1      62.43333               1                 0                1      7.950000               0                 0                0     1.2833333
#>            player_name season_years season_type team_abbreviation skater_games skater_goals skater_assists skater_points skater_plusminus skater_pim skater_toi skater_shifts skater_gwg skater_otg skater_shots skater_blocked skater_hits skater_ev_goals skater_ev_assists skater_ev_points skater_ev_toi skater_pp_goals skater_pp_assists skater_pp_points skater_pp_toi skater_pk_goals skater_pk_assists skater_pk_points skater_pk_toi

There is a lot of information above. Let’s take a closer look at their total contributions as a Tampa Bay Lightning player in terms of some key statistics.

career_stats[team_abbreviation == "TBL"][, .(
  nb_season = .N,
  games = sum(skater_games),
  goals = sum(skater_goals),
  assists = sum(skater_assists),
  points = sum(skater_points),
  plusminus = sum(skater_plusminus),
  pim = sum(skater_pim)
), .(player_name, team_abbreviation, season_type)]
#>           player_name team_abbreviation season_type nb_season games goals assists points plusminus pim
#> 1:   Martin St. Louis               TBL     regular        13   972   365     588    953        31 254
#> 2:   Martin St. Louis               TBL    playoffs         5    63    33      35     68         7  28
#> 3: Vincent Lecavalier               TBL     regular        14  1037   383     491    874      -117 746
#> 4: Vincent Lecavalier               TBL    playoffs         5    63    24      28     52         6  80

We could then conclude that, even though they were two excellent players for the Tampa Bay Lightning, St. Louis has a slight advantage over Lecavalier. The biggest difference is probably their +/- ratio, which points out that St. Louis was probably a more responsible player in defense.

2004 Stanley Cup Playoffs

The Tampa Bay Lightning won their first Stanley Cup back in 2004. Lecavalier and St. Louis were key players in this conquest, but they both fell short of winning the Conn Smythe Trophy, which has been awarded to Brad Richards. So why not adding Richards in the mix for the analysis of this subsection? No problem, let’s do it! We begin by retrieving their game logs for this particular Stanley Cup Playoffs run.

stanleycup_gamelogs <- tidy_skaters_gamelogs(
  players_id = c(ids, get_players_id("Brad Richards")),
  seasons_id = "20032004",
  regular = FALSE
)
stanleycup_gamelogs[]
#>            player_name season_years season_type       game_datetime                        venue_name team_status team_abbreviation team_shots team_score opponent_score opponent_shots opponent_abbreviation game_status game_nbot game_shootout skater_games skater_goals skater_assists skater_points skater_plusminus skater_pim skater_toi skater_shifts skater_gwg skater_otg skater_shots skater_blocked skater_hits skater_ev_goals skater_ev_assists skater_ev_points skater_ev_toi skater_pp_goals skater_pp_assists skater_pp_points skater_pp_toi skater_pk_goals skater_pk_assists skater_pk_points skater_pk_toi
#>  1:   Martin St. Louis      2003-04    playoffs 2004-04-08 23:30:00              St. Pete Times Forum        home               TBL         18          3              0             30                   NYI       final         0         FALSE            1            0              0             0                0          4   18.31667            25          0          0            2              0           0               0                 0                0      12.25000               0                 0                0     5.3833333               0                 0                0    0.68333333
#>  2:   Martin St. Louis      2003-04    playoffs 2004-04-10 19:00:00              St. Pete Times Forum        home               TBL         22          0              3             25                   NYI       final         0         FALSE            1            0              0             0                0          2   26.90000            31          0          0            2              0           2               0                 0                0      17.66667               0                 0                0     8.1333333               0                 0                0    1.10000000
#>  3:   Martin St. Louis      2003-04    playoffs 2004-04-12 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         24          3              0             28                   NYI       final         0         FALSE            1            2              0             2                2          2   20.48333            32          0          0            4              0           1               2                 0                2      16.85000               0                 0                0     2.3833333               0                 0                0    1.25000000
#>  4:   Martin St. Louis      2003-04    playoffs 2004-04-14 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         20          3              0             33                   NYI       final         0         FALSE            1            1              1             2                2          0   22.26667            29          1          0            4              0           0               0                 1                1      18.01667               0                 0                0     1.4000000               1                 0                1    2.85000000
#>  5:   Martin St. Louis      2003-04    playoffs 2004-04-16 23:30:00              St. Pete Times Forum        home               TBL         37          3              2             26                   NYI       final         1         FALSE            1            1              0             1                1          0   28.96667            35          1          1            4              1           0               1                 0                1      23.58333               0                 0                0     4.7166667               0                 0                0    0.66666667
#>  6:   Martin St. Louis      2003-04    playoffs 2004-04-23 23:00:00              St. Pete Times Forum        home               TBL         34          4              0             21                   MTL       final         0         FALSE            1            0              3             3                3          0   21.36667            28          0          0            4              0           1               0                 3                3      16.50000               0                 0                0     4.1000000               0                 0                0    0.76666667
#>  7:   Martin St. Louis      2003-04    playoffs 2004-04-25 20:00:00              St. Pete Times Forum        home               TBL         29          3              1             27                   MTL       final         0         FALSE            1            0              1             1                1          0   20.03333            28          0          0            3              1           2               0                 0                0      15.91667               0                 1                1     2.6500000               0                 0                0    1.46666667
#>  8:   Martin St. Louis      2003-04    playoffs 2004-04-27 23:00:00                       Centre Bell        away               TBL         28          4              3             31                   MTL       final         1         FALSE            1            0              2             2                0          0   24.58333            30          0          0            2              1           3               0                 1                1      20.68333               0                 1                1     3.3166667               0                 0                0    0.58333333
#>  9:   Martin St. Louis      2003-04    playoffs 2004-04-29 23:00:00                       Centre Bell        away               TBL         24          3              1             28                   MTL       final         0         FALSE            1            0              0             0                0          0   21.11667            27          0          0            2              0           0               0                 0                0      13.88333               0                 0                0     4.7833333               0                 0                0    2.45000000
#> 10:   Martin St. Louis      2003-04    playoffs 2004-05-08 19:00:00              St. Pete Times Forum        home               TBL         17          3              1             20                   PHI       final         0         FALSE            1            0              0             0               -1          0   20.65000            26          0          0            1              0           1               0                 0                0      14.43333               0                 0                0     3.5833333               0                 0                0    2.63333333
#> 11:   Martin St. Louis      2003-04    playoffs 2004-05-10 23:30:00              St. Pete Times Forum        home               TBL         31          2              6             29                   PHI       final         0         FALSE            1            1              0             1               -3          0   20.55000            30          0          0            3              0           1               0                 0                0      12.51667               1                 0                1     5.2666667               0                 0                0    2.76666667
#> 12:   Martin St. Louis      2003-04    playoffs 2004-05-13 23:00:00                   Wachovia Center        away               TBL         26          4              1             25                   PHI       final         0         FALSE            1            0              2             2                2          0   19.03333            28          0          0            0              1           2               0                 2                2      11.63333               0                 0                0     2.5333333               0                 0                0    4.86666667
#> 13:   Martin St. Louis      2003-04    playoffs 2004-05-15 19:00:00                   Wachovia Center        away               TBL         30          2              3             26                   PHI       final         0         FALSE            1            0              0             0               -1          2   25.66667            29          0          0            4              0           0               0                 0                0      15.70000               0                 0                0     7.9000000               0                 0                0    2.06666667
#> 14:   Martin St. Louis      2003-04    playoffs 2004-05-18 23:30:00              St. Pete Times Forum        home               TBL         31          4              2             30                   PHI       final         0         FALSE            1            0              1             1                0          2   18.41667            28          0          0            3              0           1               0                 1                1      16.05000               0                 0                0     1.4500000               0                 0                0    0.91666667
#> 15:   Martin St. Louis      2003-04    playoffs 2004-05-20 23:30:00                   Wachovia Center        away               TBL         29          4              5             43                   PHI       final         1         FALSE            1            0              2             2                0          0   24.78333            35          0          0            2              0           0               0                 2                2      24.11667               0                 0                0     0.0000000               0                 0                0    0.66666667
#> 16:   Martin St. Louis      2003-04    playoffs 2004-05-22 23:00:00              St. Pete Times Forum        home               TBL         32          2              1             23                   PHI       final         0         FALSE            1            0              1             1                0          0   23.41667            29          0          0            3              0           0               0                 0                0      20.93333               0                 1                1     1.4500000               0                 0                0    1.03333333
#> 17:   Martin St. Louis      2003-04    playoffs 2004-05-26 00:00:00              St. Pete Times Forum        home               TBL         24          1              4             19                   CGY       final         0         FALSE            1            1              0             1               -1          2   25.18333            31          0          0            4              0           0               0                 0                0      18.56667               1                 0                1     4.5000000               0                 0                0    2.11666667
#> 18:   Martin St. Louis      2003-04    playoffs 2004-05-28 00:00:00              St. Pete Times Forum        home               TBL         31          4              1             19                   CGY       final         0         FALSE            1            1              1             2                1          0   22.63333            30          0          0            1              1           0               0                 1                1      11.05000               1                 0                1     7.0166667               0                 0                0    4.56666667
#> 19:   Martin St. Louis      2003-04    playoffs 2004-05-30 00:00:00              Pengrowth Saddledome        away               TBL         21          0              3             18                   CGY       final         0         FALSE            1            0              0             0               -1          0   21.56667            32          0          0            2              0           1               0                 0                0      14.03333               0                 0                0     5.3166667               0                 0                0    2.21666667
#> 20:   Martin St. Louis      2003-04    playoffs 2004-06-01 00:00:00              Pengrowth Saddledome        away               TBL         24          1              0             29                   CGY       final         0         FALSE            1            0              0             0                0          0   22.81667            30          0          0            2              0           2               0                 0                0      15.06667               0                 0                0     5.5000000               0                 0                0    2.25000000
#> 21:   Martin St. Louis      2003-04    playoffs 2004-06-04 00:00:00              St. Pete Times Forum        home               TBL         28          2              3             36                   CGY       final         1         FALSE            1            1              0             1                0          0   27.68333            37          0          0            2              0           1               1                 0                1      25.86667               0                 0                0     1.1666667               0                 0                0    0.65000000
#> 22:   Martin St. Louis      2003-04    playoffs 2004-06-06 00:00:00              Pengrowth Saddledome        away               TBL         27          3              2             33                   CGY       final         2         FALSE            1            1              1             2                1          0   28.88333            39          1          1            1              1           0               1                 0                1      28.88333               0                 1                1     0.0000000               0                 0                0    0.00000000
#> 23:   Martin St. Louis      2003-04    playoffs 2004-06-08 00:00:00              St. Pete Times Forum        home               TBL         15          2              1             17                   CGY       final         0         FALSE            1            0              0             0                0          0   20.66667            30          0          0            3              1           1               0                 0                0      15.91667               0                 0                0     4.2666667               0                 0                0    0.48333333
#> 24: Vincent Lecavalier      2003-04    playoffs 2004-04-08 23:30:00              St. Pete Times Forum        home               TBL         18          3              0             30                   NYI       final         0         FALSE            1            0              0             0                0          0   17.40000            23          0          0            3              0           0               0                 0                0      12.70000               0                 0                0     4.4166667               0                 0                0    0.28333333
#> 25: Vincent Lecavalier      2003-04    playoffs 2004-04-10 19:00:00              St. Pete Times Forum        home               TBL         22          0              3             25                   NYI       final         0         FALSE            1            0              0             0               -1          0   23.73333            31          0          0            2              0           3               0                 0                0      17.68333               0                 0                0     6.0500000               0                 0                0    0.00000000
#> 26: Vincent Lecavalier      2003-04    playoffs 2004-04-12 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         24          3              0             28                   NYI       final         0         FALSE            1            0              0             0                0          0   16.11667            27          0          0            4              0           0               0                 0                0      14.25000               0                 0                0     1.8666667               0                 0                0    0.00000000
#> 27: Vincent Lecavalier      2003-04    playoffs 2004-04-14 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         20          3              0             33                   NYI       final         0         FALSE            1            0              0             0                0          0   16.56667            28          0          0            1              0           0               0                 0                0      13.71667               0                 0                0     1.8500000               0                 0                0    1.00000000
#> 28: Vincent Lecavalier      2003-04    playoffs 2004-04-16 23:30:00              St. Pete Times Forum        home               TBL         37          3              2             26                   NYI       final         1         FALSE            1            0              0             0                0          4   21.33333            32          0          0            5              0           0               0                 0                0      16.41667               0                 0                0     4.3000000               0                 0                0    0.61666667
#> 29: Vincent Lecavalier      2003-04    playoffs 2004-04-23 23:00:00              St. Pete Times Forum        home               TBL         34          4              0             21                   MTL       final         0         FALSE            1            2              1             3                3          2   19.25000            25          0          0            6              0           0               2                 1                3      13.43333               0                 0                0     5.0666667               0                 0                0    0.75000000
#> 30: Vincent Lecavalier      2003-04    playoffs 2004-04-25 20:00:00              St. Pete Times Forum        home               TBL         29          3              1             27                   MTL       final         0         FALSE            1            2              0             2                1          0   19.90000            27          0          0            4              1           0               1                 0                1      16.21667               1                 0                1     3.1500000               0                 0                0    0.53333333
#> 31: Vincent Lecavalier      2003-04    playoffs 2004-04-27 23:00:00                       Centre Bell        away               TBL         28          4              3             31                   MTL       final         1         FALSE            1            1              0             1                0          6   19.88333            24          0          0            4              0           1               1                 0                1      17.88333               0                 0                0     2.0000000               0                 0                0    0.00000000
#> 32: Vincent Lecavalier      2003-04    playoffs 2004-04-29 23:00:00                       Centre Bell        away               TBL         24          3              1             28                   MTL       final         0         FALSE            1            0              1             1                0          0   20.10000            25          0          0            3              0           1               0                 0                0      14.03333               0                 1                1     6.0166667               0                 0                0    0.05000000
#> 33: Vincent Lecavalier      2003-04    playoffs 2004-05-08 19:00:00              St. Pete Times Forum        home               TBL         17          3              1             20                   PHI       final         0         FALSE            1            0              0             0               -1          0   19.23333            22          0          0            0              0           2               0                 0                0      15.41667               0                 0                0     3.8166667               0                 0                0    0.00000000
#> 34: Vincent Lecavalier      2003-04    playoffs 2004-05-10 23:30:00              St. Pete Times Forum        home               TBL         31          2              6             29                   PHI       final         0         FALSE            1            0              1             1               -2          2   15.90000            24          0          0            6              0           0               0                 1                1      11.35000               0                 0                0     3.7000000               0                 0                0    0.85000000
#> 35: Vincent Lecavalier      2003-04    playoffs 2004-05-13 23:00:00                   Wachovia Center        away               TBL         26          4              1             25                   PHI       final         0         FALSE            1            1              0             1                1          0   15.20000            22          0          0            3              1           0               1                 0                1      12.10000               0                 0                0     3.1000000               0                 0                0    0.00000000
#> 36: Vincent Lecavalier      2003-04    playoffs 2004-05-15 19:00:00                   Wachovia Center        away               TBL         30          2              3             26                   PHI       final         0         FALSE            1            1              0             1               -1          0   20.30000            25          0          0            3              0           1               0                 0                0      12.51667               1                 0                1     7.5666667               0                 0                0    0.21666667
#> 37: Vincent Lecavalier      2003-04    playoffs 2004-05-18 23:30:00              St. Pete Times Forum        home               TBL         31          4              2             30                   PHI       final         0         FALSE            1            0              1             1               -1          0   17.58333            28          0          0            4              0           5               0                 0                0      15.31667               0                 1                1     2.0333333               0                 0                0    0.23333333
#> 38: Vincent Lecavalier      2003-04    playoffs 2004-05-20 23:30:00                   Wachovia Center        away               TBL         29          4              5             43                   PHI       final         1         FALSE            1            2              0             2                0          0   23.53333            35          0          0            6              1           2               2                 0                2      23.53333               0                 0                0     0.0000000               0                 0                0    0.00000000
#> 39: Vincent Lecavalier      2003-04    playoffs 2004-05-22 23:00:00              St. Pete Times Forum        home               TBL         32          2              1             23                   PHI       final         0         FALSE            1            0              0             0                0          2   19.28333            28          0          0            4              0           2               0                 0                0      18.00000               0                 0                0     1.1500000               0                 0                0    0.13333333
#> 40: Vincent Lecavalier      2003-04    playoffs 2004-05-26 00:00:00              St. Pete Times Forum        home               TBL         24          1              4             19                   CGY       final         0         FALSE            1            0              0             0               -1          0   21.28333            29          0          0            3              0           2               0                 0                0      17.10000               0                 0                0     3.7333333               0                 0                0    0.45000000
#> 41: Vincent Lecavalier      2003-04    playoffs 2004-05-28 00:00:00              St. Pete Times Forum        home               TBL         31          4              1             19                   CGY       final         0         FALSE            1            0              2             2                1          2   20.43333            27          0          0            4              0           5               0                 1                1      13.41667               0                 1                1     6.0000000               0                 0                0    1.01666667
#> 42: Vincent Lecavalier      2003-04    playoffs 2004-05-30 00:00:00              Pengrowth Saddledome        away               TBL         21          0              3             18                   CGY       final         0         FALSE            1            0              0             0                0          5   19.63333            27          0          0            1              0           1               0                 0                0      15.58333               0                 0                0     3.9500000               0                 0                0    0.10000000
#> 43: Vincent Lecavalier      2003-04    playoffs 2004-06-01 00:00:00              Pengrowth Saddledome        away               TBL         24          1              0             29                   CGY       final         0         FALSE            1            0              0             0                0          2   19.38333            22          0          0            2              1           3               0                 0                0      15.43333               0                 0                0     3.9500000               0                 0                0    0.00000000
#> 44: Vincent Lecavalier      2003-04    playoffs 2004-06-04 00:00:00              St. Pete Times Forum        home               TBL         28          2              3             36                   CGY       final         1         FALSE            1            0              0             0               -2          0   25.33333            34          0          0            3              0           5               0                 0                0      24.21667               0                 0                0     1.1000000               0                 0                0    0.01666667
#> 45: Vincent Lecavalier      2003-04    playoffs 2004-06-06 00:00:00              Pengrowth Saddledome        away               TBL         27          3              2             33                   CGY       final         2         FALSE            1            0              0             0                0          0   24.48333            34          0          0            2              0           0               0                 0                0      24.48333               0                 0                0     0.0000000               0                 0                0    0.00000000
#> 46: Vincent Lecavalier      2003-04    playoffs 2004-06-08 00:00:00              St. Pete Times Forum        home               TBL         15          2              1             17                   CGY       final         0         FALSE            1            0              1             1                1          0   15.96667            27          0          0            3              0           0               0                 1                1      11.88333               0                 0                0     3.9833333               0                 0                0    0.10000000
#> 47:      Brad Richards      2003-04    playoffs 2004-04-08 23:30:00              St. Pete Times Forum        home               TBL         18          3              0             30                   NYI       final         0         FALSE            1            0              0             0                1          2   22.06667            27          0          0            1              0           0               0                 0                0      15.00000               0                 0                0     4.9333333               0                 0                0    2.13333333
#> 48:      Brad Richards      2003-04    playoffs 2004-04-10 19:00:00              St. Pete Times Forum        home               TBL         22          0              3             25                   NYI       final         0         FALSE            1            0              0             0               -1          0   26.65000            31          0          0            3              0           0               0                 0                0      17.33333               0                 0                0     6.6166667               0                 0                0    2.70000000
#> 49:      Brad Richards      2003-04    playoffs 2004-04-12 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         24          3              0             28                   NYI       final         0         FALSE            1            1              2             3                2          0   18.63333            27          1          0            3              1           1               0                 2                2      15.03333               1                 0                1     2.3833333               0                 0                0    1.21666667
#> 50:      Brad Richards      2003-04    playoffs 2004-04-14 23:00:00 Nassau Veterans Memorial Coliseum        away               TBL         20          3              0             33                   NYI       final         0         FALSE            1            0              2             2                2          0   21.36667            28          0          0            3              1           0               0                 2                2      17.18333               0                 0                0     1.5666667               0                 0                0    2.61666667
#> 51:      Brad Richards      2003-04    playoffs 2004-04-16 23:30:00              St. Pete Times Forum        home               TBL         37          3              2             26                   NYI       final         1         FALSE            1            0              0             0                0          0   27.38333            34          0          0            6              1           1               0                 0                0      22.63333               0                 0                0     4.2833333               0                 0                0    0.46666667
#> 52:      Brad Richards      2003-04    playoffs 2004-04-23 23:00:00              St. Pete Times Forum        home               TBL         34          4              0             21                   MTL       final         0         FALSE            1            0              0             0                0          0   23.08333            29          0          0            6              1           0               0                 0                0      18.10000               0                 0                0     3.7666667               0                 0                0    1.21666667
#> 53:      Brad Richards      2003-04    playoffs 2004-04-25 20:00:00              St. Pete Times Forum        home               TBL         29          3              1             27                   MTL       final         0         FALSE            1            0              1             1                1          0   21.25000            26          0          0            3              0           0               0                 1                1      16.33333               0                 0                0     2.7000000               0                 0                0    2.21666667
#> 54:      Brad Richards      2003-04    playoffs 2004-04-27 23:00:00                       Centre Bell        away               TBL         28          4              3             31                   MTL       final         1         FALSE            1            2              0             2                2          0   24.78333            31          1          1            6              1           0               1                 0                1      19.68333               1                 0                1     3.8000000               0                 0                0    1.30000000
#> 55:      Brad Richards      2003-04    playoffs 2004-04-29 23:00:00                       Centre Bell        away               TBL         24          3              1             28                   MTL       final         0         FALSE            1            1              0             1                1          0   23.38333            28          1          0            3              1           0               1                 0                1      15.43333               0                 0                0     6.2000000               0                 0                0    1.75000000
#> 56:      Brad Richards      2003-04    playoffs 2004-05-08 19:00:00              St. Pete Times Forum        home               TBL         17          3              1             20                   PHI       final         0         FALSE            1            1              0             1                1          0   20.68333            27          1          0            2              0           0               1                 0                1      14.01667               0                 0                0     3.6500000               0                 0                0    3.01666667
#> 57:      Brad Richards      2003-04    playoffs 2004-05-10 23:30:00              St. Pete Times Forum        home               TBL         31          2              6             29                   PHI       final         0         FALSE            1            0              0             0                0          0   20.83333            27          0          0            2              0           0               0                 0                0      14.65000               0                 0                0     4.2833333               0                 0                0    1.90000000
#> 58:      Brad Richards      2003-04    playoffs 2004-05-13 23:00:00                   Wachovia Center        away               TBL         26          4              1             25                   PHI       final         0         FALSE            1            1              1             2                1          0   21.46667            27          0          0            4              0           0               1                 1                2      16.20000               0                 0                0     2.9166667               0                 0                0    2.35000000
#> 59:      Brad Richards      2003-04    playoffs 2004-05-15 19:00:00                   Wachovia Center        away               TBL         30          2              3             26                   PHI       final         0         FALSE            1            0              0             0               -1          0   21.96667            26          0          0            2              0           0               0                 0                0      13.80000               0                 0                0     6.5666667               0                 0                0    1.60000000
#> 60:      Brad Richards      2003-04    playoffs 2004-05-18 23:30:00              St. Pete Times Forum        home               TBL         31          4              2             30                   PHI       final         0         FALSE            1            2              0             2               -1          0   22.65000            28          1          0            6              1           0               0                 0                0      20.46667               2                 0                2     2.1833333               0                 0                0    0.00000000
#> 61:      Brad Richards      2003-04    playoffs 2004-05-20 23:30:00                   Wachovia Center        away               TBL         29          4              5             43                   PHI       final         1         FALSE            1            0              1             1                0          0   25.30000            32          0          0            2              1           0               0                 0                0      24.20000               0                 1                1     0.3333333               0                 0                0    0.76666667
#> 62:      Brad Richards      2003-04    playoffs 2004-05-22 23:00:00              St. Pete Times Forum        home               TBL         32          2              1             23                   PHI       final         0         FALSE            1            0              2             2                0          0   23.38333            26          0          0            8              0           1               0                 1                1      20.40000               0                 1                1     1.7833333               0                 0                0    1.20000000
#> 63:      Brad Richards      2003-04    playoffs 2004-05-26 00:00:00              St. Pete Times Forum        home               TBL         24          1              4             19                   CGY       final         0         FALSE            1            0              1             1               -2          0   25.70000            28          0          0            2              0           0               0                 0                0      17.80000               0                 1                1     5.3166667               0                 0                0    2.58333333
#> 64:      Brad Richards      2003-04    playoffs 2004-05-28 00:00:00              St. Pete Times Forum        home               TBL         31          4              1             19                   CGY       final         0         FALSE            1            1              1             2                2          2   22.90000            30          1          0            4              1           0               1                 1                2      11.55000               0                 0                0     6.3666667               0                 0                0    4.98333333
#> 65:      Brad Richards      2003-04    playoffs 2004-05-30 00:00:00              Pengrowth Saddledome        away               TBL         21          0              3             18                   CGY       final         0         FALSE            1            0              0             0               -1          0   24.13333            28          0          0            6              1           1               0                 0                0      14.53333               0                 0                0     6.0166667               0                 0                0    3.58333333
#> 66:      Brad Richards      2003-04    playoffs 2004-06-01 00:00:00              Pengrowth Saddledome        away               TBL         24          1              0             29                   CGY       final         0         FALSE            1            1              0             1                0          0   21.76667            27          1          0            4              0           0               0                 0                0      14.71667               1                 0                1     6.3666667               0                 0                0    0.68333333
#> 67:      Brad Richards      2003-04    playoffs 2004-06-04 00:00:00              St. Pete Times Forum        home               TBL         28          2              3             36                   CGY       final         1         FALSE            1            0              1             1               -1          0   27.15000            34          0          0            5              0           1               0                 0                0      25.40000               0                 1                1     1.6500000               0                 0                0    0.10000000
#> 68:      Brad Richards      2003-04    playoffs 2004-06-06 00:00:00              Pengrowth Saddledome        away               TBL         27          3              2             33                   CGY       final         2         FALSE            1            2              1             3               -1          0   29.41667            38          0          0            6              0           0               0                 1                1      29.41667               2                 0                2     0.0000000               0                 0                0    0.00000000
#> 69:      Brad Richards      2003-04    playoffs 2004-06-08 00:00:00              St. Pete Times Forum        home               TBL         15          2              1             17                   CGY       final         0         FALSE            1            0              1             1                0          0   23.90000            30          0          0            1              0           0               0                 0                0      17.13333               0                 1                1     6.3500000               0                 0                0    0.41666667
#>            player_name season_years season_type       game_datetime                        venue_name team_status team_abbreviation team_shots team_score opponent_score opponent_shots opponent_abbreviation game_status game_nbot game_shootout skater_games skater_goals skater_assists skater_points skater_plusminus skater_pim skater_toi skater_shifts skater_gwg skater_otg skater_shots skater_blocked skater_hits skater_ev_goals skater_ev_assists skater_ev_points skater_ev_toi skater_pp_goals skater_pp_assists skater_pp_points skater_pp_toi skater_pk_goals skater_pk_assists skater_pk_points skater_pk_toi

Again, there is a lot of information above. Let’s compare each player’s success against their different opponents.

stanleycup_gamelogs[order(game_datetime)][, .(
  games = sum(skater_games),
  goals = sum(skater_goals),
  assists = sum(skater_assists),
  points = sum(skater_points),
  plusminus = sum(skater_plusminus),
  toi = sum(skater_toi)
), .(player_name, opponent_abbreviation)]
#>            player_name opponent_abbreviation games goals assists points plusminus       toi
#>  1:   Martin St. Louis                   NYI     5     4       1      5         5 116.93333
#>  2: Vincent Lecavalier                   NYI     5     0       0      0        -1  95.15000
#>  3:      Brad Richards                   NYI     5     1       4      5         4 116.10000
#>  4:   Martin St. Louis                   MTL     4     0       6      6         4  87.10000
#>  5: Vincent Lecavalier                   MTL     4     5       2      7         4  79.13333
#>  6:      Brad Richards                   MTL     4     3       1      4         4  92.50000
#>  7:   Martin St. Louis                   PHI     7     1       6      7        -3 152.51667
#>  8: Vincent Lecavalier                   PHI     7     4       2      6        -4 131.03333
#>  9:      Brad Richards                   PHI     7     4       4      8         0 156.28333
#> 10:   Martin St. Louis                   CGY     7     4       2      6         0 169.43333
#> 11: Vincent Lecavalier                   CGY     7     0       3      3        -1 146.51667
#> 12:      Brad Richards                   CGY     7     4       5      9        -3 174.96667

Even though there is no objective way of ranking each player’s contribution, one could argue that Lecavalier was the best player against the Montreal Canadiens (2nd round), that St. Louis and Richards were kind of nose-to-nose against the New York Islanders (1st round) and the Philadelphia Flyers (Eastern Semi-Final) and that Richards probably locked in the Conn Smythe by being the best player against the Calgary Flames in the Final.

Instead of splitting the data by opponents, we could have split it between home and away games to see if one was better than the others when playing at the St. Pete Times Forum during this playoff year.

stanleycup_gamelogs[, .(
  games = sum(skater_games),
  goals = sum(skater_goals),
  assists = sum(skater_assists),
  points = sum(skater_points),
  plusminus = sum(skater_plusminus),
  points_per_game = sum(skater_points) / sum(skater_games)
), .(player_name, team_status)]
#>           player_name team_status games goals assists points plusminus points_per_game
#> 1:   Martin St. Louis        home    13     5       7     12         1       0.9230769
#> 2:   Martin St. Louis        away    10     4       8     12         5       1.2000000
#> 3: Vincent Lecavalier        home    13     4       6     10        -2       0.7692308
#> 4: Vincent Lecavalier        away    10     5       1      6         0       0.6000000
#> 5:      Brad Richards        home    13     4       7     11         0       0.8461538
#> 6:      Brad Richards        away    10     8       7     15         5       1.5000000

One could argue that, while Lecavalier was slightly better at home and St. Louis was slightly better away, Richards was clearly a more dominant player for that playoff year while he was anywhere but in the Sunshine State.

Conclusion

As we saw in this short introduction to tidynhl, the main goal of the package is to make it easy to retrieve NHL data, even for R beginners.