---
title: "Climate Normals: Terms and Units"
author: "Steffi LaZerte"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Climate Normals: Terms and Units}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
library(weathercan)
library(dplyr)
library(tidyr)
library(stringr)
```

This table shows details regarding original column (measurement) names and units of all climate normals measurements. It further provides links back to the ECCC glossary for more details.

See the ECCC website on climate normals for more details: <`r paste0("https://www.canada.ca/en/environment-climate-change/services/",
            "climate-change/canadian-centre-climate-services/display-download/",
            "technical-documentation-climate-normals.html")`>

For details on weather measurements, see the `glossary` vignette.

### General descriptions
```{r, asis = TRUE, echo = FALSE}
glossary_normals[1:18,] %>%
  mutate(description = stringr::str_replace_all(description, "\\n", " ")) %>%
  knitr::kable()
```


### Original names and units
These represent the original ECCC measurement names with units and their corresponding measurements in `weathercan`.

```{r, echo = FALSE}
g <- glossary_normals[19:nrow(glossary_normals),] %>%
  select(-description) %>%
  mutate(group = str_detect(weathercan_name, "title"),
         group = cumsum(group)) %>%
  filter(weathercan_name != "probability") %>%
  group_by(group) %>% 
  mutate(title = ECCC_name[1]) %>%
  group_by(title) %>%
  filter(!str_detect(weathercan_name, "title")) %>%
  select(-group) %>%
  nest()
```

```{r, results = "asis", echo = FALSE}
for(t in seq_len(nrow(g))) {
  cat("<center><h4>", str_to_title(g$title[t]), "</h3></center>\n")
  print(knitr::kable(g$data[[t]], format = "html"))
  cat("\n")
}
```
