-
Notifications
You must be signed in to change notification settings - Fork 0
/
getInputs.R
61 lines (51 loc) · 1.33 KB
/
getInputs.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
50
51
52
53
54
55
56
57
58
59
60
61
library(magrittr)
library(readr)
library(dplyr)
ds_ <- read_csv(
"case-death-rr-state.csv",
col_types = cols_only(
date = col_date(),
state = col_character(),
cases = col_number(),
deaths = col_number(),
RR = col_number()
)
)
dc_ <- read_csv(
"case-death-rr.csv",
col_types = cols_only(
date = col_date(),
fips = col_character(),
cases = col_number(),
deaths = col_number(),
RR = col_number()
)
)
# State input data current as of 2022-01-11. Returned as a list for
# ease-of-use with Covidestim package
getStateInputs <- function(stateName) {
d1 <- filter(ds_, state == stateName)
list(
cases = select(d1, date, observation = cases),
deaths = select(d1, date, observation = deaths),
RR = select(d1, date, observation = RR),
ndays = nrow(d1)
)
}
# County input data current as of 2022-01-11. Returned as a list for
# ease-of-use with Covidestim package
getCountyInputs <- function(fipsCode) {
d1 <- filter(dc_, fips == fipsCode)
list(
cases = select(d1, date, observation = cases),
deaths = select(d1, date, observation = deaths),
RR = select(d1, date, observation = RR),
ndays = nrow(d1)
)
}
getInputs <- function(geoName) {
if (stringr::str_detect(geoName, '[0-9]{5}'))
return(getCountyInputs(geoName))
else
return(getStateInputs(geoName))
}