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 10 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
7 changes: 7 additions & 0 deletions R/epipredict-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@
#' by the Johns Hopkins University on behalf of its Center for Systems Science in Engineering.
#' Copyright Johns Hopkins University 2020.
"counts_subset"

#' COVID Cases for Canada
#'
#' THIS IS A STUB This dataset covers the period from March 2020 to March 2023 and is
#' used in the [epipredict] slide vignette.
"cancovid"

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
5 changes: 5 additions & 0 deletions data-raw/cancovid.R
nmdefries marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## code to prepare `cancovid` dataset goes here

library(dplyr)
library(epiprocess)
library(readr)
library(purrr)

path_to_csvs <- here::here("../../COVID-BC/Covid19Canada/updates.nosync/")
files <- list.files(path_to_csvs)
ca_as_ofs <- as.Date(substr(files, 1, 10)) %>%
Expand Down
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
5 changes: 3 additions & 2 deletions data-raw/ctis_covid_behaviours.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## code to prepare `ctis_covid_behaviours` dataset goes here

library(dplyr)
library(epidatr)

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

pop_dat <- state_census %>% select(abbr, pop)

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
3 changes: 3 additions & 0 deletions data-raw/state_census.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
library(dplyr)
library(covidcast)

state_census <- covidcast::state_census %>%
select(STATE, NAME, POPESTIMATE2019, ABBR) %>%
rename(abbr = ABBR, name = NAME, pop = POPESTIMATE2019, fips = STATE) %>%
Expand Down