-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathB-county-charts-html.Rmd
129 lines (88 loc) · 2.67 KB
/
B-county-charts-html.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
font: Lato
fontsize: 10pt
geometry: left=1in,right=1in,top=0.35in,bottom=0.6in
header-includes: \input{preamble.tex}
output:
html_document: default
pdf_document: default
sansfont: Lato
urlcolor: null
params:
county: "Los Angeles"
start_date: "2020-04-15"
---
\raggedright
```{r rmarkdown-setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(dev = "cairo_pdf")
options(knitr.kable.NA = "")
options(kableExtra.latex.load_packages = FALSE)
# Knit RMarkdown
library(knitr)
# Tables
library(kableExtra)
# Data Cleaning pipeline
library(tidyverse)
library(dplyr)
library(scales) # formatting numbers
library(arrow) # read parquets
library(zoo) # moving averages
library(reshape2)
# Plotting
library(ggplot2)
library(ggthemes)
library(plotly) #interactive charts
```
```{r import-data}
us_county<-arrow::read_parquet("../data/us-county-time-series.parquet", as_tibble=TRUE)
ca_hospitalizations<-read.csv("https://raw.githubusercontent.com/CityOfLosAngeles/covid19-indicators/master/data/ca-hospital-and-surge-capacity.csv")
# Call parameters from our utils files
source("../notebooks/r_utils.R")
YESTERDAY_DATE <-YESTERDAY_DATE
TWO_WEEKS_AGO <- TWO_WEEKS_AGO
# Call parameters from utils files
source("../notebooks/r_chart_utils.R")
# Chart parameters
NAVY<-NAVY
MAROON<- MAROON
LIGHT_GRAY<-LIGHT_GRAY
```
```{r select-parameter, echo = FALSE}
source("../notebooks/r_utils.R")
cases <- prep_county(us_county, params$county, params$start_date)
hospitalizations <-prep_hospital(ca_hospitalizations, params$county, params$start_date)
```
```{r get-caption, echo = FALSE}
subset_df <-cases %>%
subset(date ==YESTERDAY_DATE) %>%
select(c("date", "cases", "deaths"))
```
# Markdown Header 1
## Markdown Header 2
### Markdown Header 3
#### Markdown Header 4
**bold** or *italic* or just regular words
\clatitle{Daily Coronavirus Report}
\clasubtitle{Subtitle}
## `r {params$county}` County
As of `r YESTERDAY_DATE`, there have been `r comma(subset_df$cases)` cumulative cases and `r comma(subset_df$deaths)` cumulative deaths in `r params$county` County.
```{r plot-cases, echo=FALSE}
source("../notebooks/r_chart_utils.R")
#https://stackoverflow.com/questions/38733403/edit-labels-in-tooltip-for-plotly-maps-using-ggplot2-in-r
cases_html<-plotCasesHTML(cases,
chart_title="New Cases: 7-day avg")
cases_html %>% ggplotly(
tooltip=c("date", "new_cases_avg7")
)
```
```{r plot-deaths, echo=FALSE}
deaths_html<-plotDeathsHTML(cases,
chart_title="New Deaths: 7-day avg")
deaths_html %>% ggplotly(
tooltip=c("date", "new_deaths_avg7")
)
```
\contactinfo{}