-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdates.R
49 lines (35 loc) · 1.33 KB
/
dates.R
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
march5 <-read.csv('./testnumbers/2020-03-05.csv')
march6 <-read.csv('./testnumbers/2020-03-06.csv')
march8 <-read.csv('./testnumbers/2020-03-08.csv')
march5$X <- NULL
march6$X <- NULL
march8$X <- NULL
march5$date <- '2020-03-05'
march6$date <- '2020-03-06'
march8$date <- '2020-03-08'
march5$state <- as.character(march5$state)
march5["Total", "positive"] <- sum(march5[, "positive"], na.rm = TRUE)
march5["Total", "negative"] <- sum(march5[, "negative"], na.rm = TRUE)
march5["Total", "pending"] <- sum(march5[, "pending"], na.rm = TRUE)
march5["Total", "total"] <- sum(march5[, "total"], na.rm = TRUE)
march5["Total", "population"] <- sum(march5[, "population"], na.rm = TRUE)
march5["Total", "state"] <- "Total"
march5 <- march5 %>%
mutate(tests_per_million = total/(population/1000000)) %>%
mutate(pct_positive = positive/(positive+negative))
write.csv(march5, './testnumbers/2020-03-05.csv', row.names = FALSE)
write.csv(march6, './testnumbers/2020-03-06.csv', row.names = FALSE)
write.csv(march8, './testnumbers/2020-03-08.csv', row.names = FALSE)
all <- march8 %>%
bind_rows(march6) %>%
bind_rows(march5)
write.csv(all, './testnumbers/all.csv', row.names = FALSE)
totals <- all %>%
filter(state == 'Total')
fig <- plot_ly(
x = totals$date,
y = totals$delta,
name = "Testing totals",
type = 'scatter', mode = 'lines'
)
fig