---
title: "Team_Performance_by_Time_Period"
author: "Data Punk"
date: "2024-10-20"
output: html_document
---

License Information

MIT License

Copyright (c) 2024 Data Punk Hockey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


```{r setup, include=FALSE}

library(dplyr)
library(knitr)
library(kableExtra)

```



```{r}

nhl_stats <- read.csv("../data/clean_historical_nhl_stats.csv")

```



```{r}

top_teams_by_time_period <- nhl_stats %>%
  group_by(TIME_PERIOD) %>%
  arrange(desc(PTS_PCT)) %>%
  slice_head(n = 1) %>%
  select(TIME_PERIOD, TEAM, PTS_PCT)

print(top_teams_by_time_period)

```

```{r}

colnames(top_teams_by_time_period) <- c("ERA", "TEAM", "PTS PCT")

top_teams_by_time_period %>%
  kable("html", caption = "Top Team by Era based on Points Percent") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),
                full_width = F, 
                position = "center") %>%
  column_spec(1, bold = T, border_right = T) %>%   
  column_spec(2, italic = T, border_right = T) %>%   
  column_spec(3, color = "red") %>%   
  add_header_above(c(" " = 1, "Top Teams" = 2)) 

write.csv(top_teams_by_time_period, "Top_Teams_by_Era.csv", row.names = FALSE)

```

