Skip to content

Commit 63cb820

Browse files
authored
Merge pull request #536 from cmu-delphi/ds/file
refactor: remove Suggests dependence on covidcast
2 parents daeb5df + 9213b23 commit 63cb820

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: epiprocess
33
Title: Tools for basic signal processing in epidemiology
4-
Version: 0.9.3
4+
Version: 0.9.4
55
Authors@R: c(
66
person("Jacob", "Bien", role = "ctb"),
77
person("Logan", "Brooks", , "[email protected]", role = c("aut", "cre")),
@@ -35,7 +35,7 @@ Imports:
3535
checkmate,
3636
cli,
3737
data.table,
38-
dplyr (>= 1.0.8),
38+
dplyr (>= 1.1.0),
3939
genlasso,
4040
ggplot2,
4141
glue,
@@ -53,11 +53,11 @@ Imports:
5353
vctrs,
5454
waldo
5555
Suggests:
56-
covidcast,
5756
devtools,
5857
epidatr,
5958
knitr,
6059
outbreaks,
60+
readr,
6161
rmarkdown,
6262
testthat (>= 3.1.5),
6363
withr

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.x.y will indicat
1717
syntax.
1818
- Improved validation of `.window_size` arguments.
1919

20+
## Cleanup
21+
22+
- Removed vignette dependency on `covidcast`.
23+
2024
# epiprocess 0.9
2125

2226
## Breaking changes

data-raw/jhu_csse_county_level_subset.R

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
library(readr)
12
library(epidatr)
2-
library(covidcast)
33
library(epiprocess)
44
library(dplyr)
55

6-
# Use covidcast::county_census to get the county and state names
7-
y <- covidcast::county_census %>%
6+
y <- read_csv("https://github.com/cmu-delphi/covidcast/raw/c89e4d295550ba1540d64d2cc991badf63ad04e5/Python-packages/covidcast-py/covidcast/geo_mappings/county_census.csv", # nolint: line_length_linter
7+
col_types = cols(
8+
FIPS = col_character(),
9+
STNAME = col_character(),
10+
CTYNAME = col_character()
11+
)
12+
) %>%
813
filter(STNAME %in% c("Massachusetts", "Vermont"), STNAME != CTYNAME) %>%
914
select(geo_value = FIPS, county_name = CTYNAME, state_name = STNAME)
1015

@@ -18,7 +23,7 @@ jhu_csse_county_level_subset <- pub_covidcast(
1823
time_values = epirange(20200601, 20211231),
1924
) %>%
2025
select(geo_value, time_value, cases = value) %>%
21-
full_join(y, by = "geo_value") %>%
26+
inner_join(y, by = "geo_value", relationship = "many-to-one", unmatched = c("error", "drop")) %>%
2227
as_epi_df()
2328

2429
usethis::use_data(jhu_csse_county_level_subset, overwrite = TRUE)

vignettes/aggregation.Rmd

+19-12
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ kinds of tasks with `epi_df` objects. We'll work with county-level reported
1313
COVID-19 cases in MA and VT.
1414

1515
```{r, message = FALSE, eval= FALSE, warning= FALSE}
16+
library(readr)
1617
library(epidatr)
17-
library(covidcast)
1818
library(epiprocess)
1919
library(dplyr)
2020
21-
# Use covidcast::county_census to get the county and state names
22-
y <- covidcast::county_census %>%
21+
# Get mapping between FIPS codes and county&state names:
22+
y <- read_csv("https://github.com/cmu-delphi/covidcast/raw/c89e4d295550ba1540d64d2cc991badf63ad04e5/Python-packages/covidcast-py/covidcast/geo_mappings/county_census.csv", # nolint: line_length_linter
23+
col_types = c(
24+
FIPS = col_character(),
25+
CTYNAME = col_character(),
26+
STNAME = col_character()
27+
)
28+
) %>%
2329
filter(STNAME %in% c("Massachusetts", "Vermont"), STNAME != CTYNAME) %>%
2430
select(geo_value = FIPS, county_name = CTYNAME, state_name = STNAME)
2531
@@ -33,15 +39,15 @@ x <- pub_covidcast(
3339
time_values = epirange(20200601, 20211231),
3440
) %>%
3541
select(geo_value, time_value, cases = value) %>%
36-
full_join(y, by = "geo_value") %>%
42+
inner_join(y, by = "geo_value", relationship = "many-to-one", unmatched = c("error", "drop")) %>%
3743
as_epi_df(as_of = as.Date("2024-03-20"))
3844
```
3945

4046
The data contains 16,212 rows and 5 columns.
4147

4248
```{r, echo=FALSE, warning=FALSE, message=FALSE}
49+
library(readr)
4350
library(epidatr)
44-
library(covidcast)
4551
library(epiprocess)
4652
library(dplyr)
4753
@@ -110,15 +116,16 @@ help avoid bugs in further downstream data processing tasks.
110116
Let's first remove certain dates from our data set to create gaps:
111117

112118
```{r}
119+
state_naming <- read_csv("https://github.com/cmu-delphi/covidcast/raw/c89e4d295550ba1540d64d2cc991badf63ad04e5/Python-packages/covidcast-py/covidcast/geo_mappings/state_census.csv", # nolint: line_length_linter
120+
col_types = c(NAME = col_character(), ABBR = col_character())
121+
) %>%
122+
transmute(state_name = NAME, abbr = tolower(ABBR)) %>%
123+
as_tibble()
124+
113125
# First make geo value more readable for tables, plots, etc.
114126
x <- x %>%
115-
mutate(
116-
geo_value = paste(
117-
substr(county_name, 1, nchar(county_name) - 7),
118-
name_to_abbr(state_name),
119-
sep = ", "
120-
)
121-
) %>%
127+
inner_join(state_naming, by = "state_name", relationship = "many-to-one", unmatched = c("error", "drop")) %>%
128+
mutate(geo_value = paste(substr(county_name, 1, nchar(county_name) - 7), state_name, sep = ", ")) %>%
122129
select(geo_value, time_value, cases)
123130
124131
xt <- as_tsibble(x) %>% filter(cases >= 3)

0 commit comments

Comments
 (0)