-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
241 lines (160 loc) · 5.29 KB
/
index.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
---
title: "Covid-19 Testing Progress"
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
orientation: rows
---
```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(DT)
library(plotly)
today <- read.csv("./testnumbers/2020-03-12.csv")
all <- read.csv('./testnumbers/all.csv')
```
Introduction {.sidebar}
-------------------------------------
This website aims to track the numbers of SARC-CoV-2 tests performed across the United States. The data is obtained daily from the websites of state health departments which report that information.
```{r}
# shiny inputs defined here
```
Row
-----------------------------------------------------------------------
### States or territories reporting
```{r}
valueBox(32, icon = "fa-flag-usa")
```
### Tests per million residents
```{r}
valueBox(23, icon = "fa-vials")
```
### Growth in the number of tests compared to the previous day
```{r}
valueBox("59%",
icon = "fa-chart-line",
color = "warning")
```
### Share of positives
```{r}
valueBox("20%",
icon = "fa-chart-line",
color = "warning")
```
Row {.tabset data-height=1400}
-----------------------------------------------------------------------
### March 12
```{r}
covid <- all %>%
filter(date == "2020-03-12")
covid %>%
select(state, total, delta, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', '+ tests since March 11', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2) %>%
formatPercentage('delta', 2)
```
### March 11
```{r}
covid <- all %>%
filter(date == "2020-03-11")
covid %>%
select(state, total, delta, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', '+ tests since March 9', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2) %>%
formatPercentage('delta', 2)
```
### March 9
```{r}
covid <- all %>%
filter(date == "2020-03-09")
covid %>%
select(state, total, delta, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', '+ tests since March 8', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2) %>%
formatPercentage('delta', 2)
```
### March 8
```{r}
covid <- all %>%
filter(date == "2020-03-08")
covid %>%
select(state, total, delta, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', '+ tests since March 6', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2) %>%
formatPercentage('delta', 2)
```
### March 6
```{r}
covid <- all %>%
filter(date == "2020-03-06")
covid %>%
select(state, total, delta, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', '+ tests since March 5', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2) %>%
formatPercentage('delta', 2)
```
### March 5
```{r}
covid <- all %>%
filter(date == "2020-03-05")
covid %>%
select(state, total, tests_per_million, pct_positive, positive, negative, pending) %>%
datatable(options = list(dom = 't', pageLength = 50, style = 'bootstrap'), colnames = c('State', 'Total tests', 'Tests per million', '% positive', '+', '-', 'Pending'), rownames = FALSE) %>%
formatRound('tests_per_million', 2) %>%
formatPercentage('pct_positive', 2)
```
Row
-----------------------------------------------------------------------
### Tests per million residents
```{r}
today$code <- state.abb[match(today$state, state.name)]
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showlakes = TRUE,
lakecolor = toRGB('white')
)
today$rounded <- round(today$tests_per_million, digits = 0)
map <- plot_geo(today, locationmode = 'USA-states')
map <- map %>% add_trace(
z = ~rounded, text = NULL, locations = ~code,
color = ~tests_per_million, colors = 'Reds'
)
map <- map %>% colorbar(title = "Tests per million")
map <- map %>% layout(
geo = g
)
map
```
Row
-----------------------------------------------------------------------
### Number of tests
```{r}
totals <- all %>%
filter(state == 'Total')
fig <- plot_ly(
x = totals$date,
y = totals$total,
name = "Testing totals",
type = 'bar'
)
fig
```
### Day-on-day growth in testing
```{r}
totals <- all %>%
filter(state == 'Total')
fig <- plot_ly(
x = totals$date,
y = totals$delta,
name = "Testing totals",
type = 'bar'
) %>%
layout(yaxis = list(tickformat = "%"))
fig
```