
```{r, include = FALSE}
knitr::opts_chunk$set(echo = FALSE, eval = TRUE,
                      fig.width = 12, fig.height = 12,
                      message = FALSE,
                      warning = FALSE,
                      dpi = 300)
```


`r if (show_title) paste0('#### ', stringr::str_to_title(region_name))`

```{r}
library(tibble)
library(knitr)
library(kableExtra)
library(here)

if (!exists("case_def")) {
  case_def <- "case"
}

if (!exists("report_growth")) {
  report_growth <- TRUE
}
```

`r paste(c(rep("#", title_depth), paste0(" Summary (estimates as of the ", latest_date, ")")), collapse = "")`


`r paste0("*Table ",  summary_tables + index, ": Latest estimates (as of the ", latest_date,  ") of the number of confirmed ", case_def, "s by date of infection, the expected change in daily confirmed ", case_def, "s, the effective reproduction number, the growth rate, and the doubling time (when negative this corresponds to the halving time). The median and 90% credible interval is shown for each numeric estimate.*")`
<br>
```{r}
readRDS(here::here(file.path(region_path, region, "latest/summary.rds"))) %>% 
.[, 1:2] %>% 
knitr::kable(col.names = c("", "Estimate"), booktabs = TRUE) %>% 
    kableExtra::kable_styling(latex_options = c("striped", "hold_position"),
                full_width = TRUE)
```


`r paste(c(rep("#", title_depth), " Confirmed ", case_def, "s, their estimated date of report, date of infection, and time-varying reproduction number estimates"), collapse = "")`

```{r, fig.height = 9, fig.width = 8, out.width = "90%"}
knitr::include_graphics(here::here(file.path(region_path, region, "latest/summary_plot.png")))
```

<br>
`r paste0("*Figure ",  summary_figures + 1 + (index - 1) * 2, ": A.) Confirmed ",  case_def, "s by date of report (bars) and their estimated date of report. B.) Confirmed ",  case_def, "s by date of report (bars) and their estimated date of infection. C.) Time-varying estimate of the effective reproduction number (lightest ribbon = 90% credible interval; darker ribbon = the 50% credible interval, darkest ribbon = 20% credible interval). Estimates from existing data are shown up to the ", latest_date, ifelse(report_forecast, " from when forecasts are shown. These should be considered indicative only", ""),  ". Estimates based on partial data have been adjusted for right truncation of infections. The vertical dashed line indicates the date of report generation. Uncertainty has been curtailed to a maximum of ten times the maximum number of reported cases for plotting purposes.*")`



