Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load libraries in data-generating scripts #3

Merged
merged 19 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Authors@R:
person(c("Daniel", "J."), "McDonald", , "[email protected]", role = c("cre", "aut"))
Description: This package contains data sets used to compile vignettes and
other documentation in Delphi R Packages. The goal is to avoid calls
to the Delphi Epidata API, and deposit some examples here for easy
to the Delphi Epidata API, and to deposit some examples here for easy
offline use.
License: MIT + file LICENSE
Depends:
Expand All @@ -16,6 +16,7 @@ Suggests:
dplyr,
epidatr,
epipredict,
epiprocess,
here,
lubridate,
magrittr,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
library(dplyr)
library(epidatr)
library(epiprocess)

dv_subset <- covidcast(
data_source = "doctor-visits",
signals = "smoothed_adj_cli",
Expand Down
25 changes: 0 additions & 25 deletions data-raw/cancovid.R
nmdefries marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

4 changes: 4 additions & 0 deletions data-raw/cases_deaths_subset.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
library(dplyr)
library(epidatr)
library(epiprocess)

nmdefries marked this conversation as resolved.
Show resolved Hide resolved
confirmed_7dav_incidence_prop <- covidcast(
data_source = "jhu-csse",
signals = "confirmed_7dav_incidence_prop",
Expand Down
4 changes: 4 additions & 0 deletions data-raw/counts_subset.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## code to prepare jhu_incidence_num dataset goes here

library(dplyr)
library(epidatr)
library(epiprocess)

x <- covidcast(
data_source = "jhu-csse",
signals = "confirmed_incidence_num",
Expand Down
8 changes: 6 additions & 2 deletions data-raw/covid_case_death_rates.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
library(dplyr)
library(epidatr)
library(epiprocess)

x <- covidcast(
data_source = "jhu-csse",
signals = "confirmed_7dav_incidence_prop",
Expand All @@ -20,8 +24,8 @@ y <- covidcast(
fetch() %>%
select(geo_value, time_value, death_rate = value)

case_death_rate_subset <- x %>%
covid_case_death_rates <- x %>%
full_join(y, by = c("geo_value", "time_value")) %>%
as_epi_df()

usethis::use_data(case_death_rate_subset, overwrite = TRUE)
usethis::use_data(covid_case_death_rates, overwrite = TRUE)
5 changes: 5 additions & 0 deletions data-raw/covid_incidence_county_subset.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Use covidcast::county_census to get the county and state names
library(dplyr)
library(covidcast)
library(epidatr)
library(epiprocess)

y <- covidcast::county_census %>%
filter(STNAME %in% c("Massachusetts", "Vermont"), STNAME != CTYNAME) %>%
select(geo_value = FIPS, county_name = CTYNAME, state_name = STNAME)
Expand Down
6 changes: 5 additions & 1 deletion data-raw/covid_incidence_outliers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
incidence_num_outlier_example <- covidcast(
library(dplyr)
library(epidatr)
library(epiprocess)

covid_incidence_outliers <- covidcast(
data_source = "jhu-csse",
signals = "confirmed_incidence_num",
time_type = "day",
Expand Down
6 changes: 5 additions & 1 deletion data-raw/ctis_covid_behaviours.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## code to prepare `ctis_covid_behaviours` dataset goes here

library(dplyr)
library(epidatr)
library(covidcast)

behav_ind_mask <- covidcast(
data_source = "fb-survey",
signals = "smoothed_wwearing_mask_7d",
Expand All @@ -20,7 +24,7 @@ behav_ind_distancing <- covidcast(
fetch() %>%
select(geo_value, time_value, distancing = value)

pop_dat <- state_census %>% select(abbr, pop)
pop_dat <- state_census %>% select(abbr = ABBR, pop = POPESTIMATE2019)
nmdefries marked this conversation as resolved.
Show resolved Hide resolved

ctis_covid_behaviours <- behav_ind_mask %>%
full_join(behav_ind_distancing, by = c("geo_value", "time_value"))
Expand Down
3 changes: 2 additions & 1 deletion data-raw/jhu_confirmed_cumulative_num.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## code to prepare `jhu_confirmed_cumulative_num` dataset goes here
library(dplyr)
library(epidatr)

jhu_confirmed_cumulative_num <- covidcast(
data_source = "jhu-csse",
Expand Down
5 changes: 4 additions & 1 deletion data-raw/state_census.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
state_census <- covidcast::state_census %>%
library(dplyr)
library(covidcast)

state_census <- state_census %>%
nmdefries marked this conversation as resolved.
Show resolved Hide resolved
select(STATE, NAME, POPESTIMATE2019, ABBR) %>%
rename(abbr = ABBR, name = NAME, pop = POPESTIMATE2019, fips = STATE) %>%
mutate(abbr = tolower(abbr)) %>%
Expand Down