Skip to content

Commit d08c6cc

Browse files
committed
change join type on covid_incidence_county_subset
1 parent de3289f commit d08c6cc

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

R/sysdata.rda

-8.21 KB
Binary file not shown.

data-raw/_run_all.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ for (file in files) {
1010
# File is a helper script and does not generate data.
1111
next
1212
}
13-
path <- here(file)
13+
path <- here(file.path("data-raw", file))
1414
message("running ", path, " ...")
1515
source(path)
1616
}

data-raw/covid_incidence_county_subset_tbl.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
library(dplyr)
2-
library(covidcast)
32
library(epidatr)
43

54
source(here::here("data-raw/_helper.R"))
65

76
d <- as.Date("2024-03-20")
87

9-
# Use covidcast::county_census to get the county and state names
10-
y <- covidcast::county_census %>%
8+
# Previously, we were using `covidcast::county_census`, but covidcast is large and complicated to install (due to `sf` dependency). Instead, read the file directly from GitHub.
9+
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
10+
col_types = cols(
11+
FIPS = col_character(),
12+
STNAME = col_character(),
13+
CTYNAME = col_character()
14+
)
15+
) %>%
1116
filter(STNAME %in% c("Massachusetts", "Vermont"), STNAME != CTYNAME) %>%
1217
select(geo_value = FIPS, county_name = CTYNAME, state_name = STNAME)
1318

@@ -22,7 +27,7 @@ covid_incidence_county_subset_tbl <- pub_covidcast(
2227
as_of = d
2328
) %>%
2429
select(geo_value, time_value, cases = value) %>%
25-
full_join(y, by = "geo_value") %>%
30+
inner_join(y, by = "geo_value", relationship = "many-to-one", unmatched = c("error", "drop")) %>%
2631
as_tibble()
2732

2833
# We're trying to do:

0 commit comments

Comments
 (0)