Skip to content

Commit

Permalink
add covid data for assessments
Browse files Browse the repository at this point in the history
  • Loading branch information
avallecam committed Mar 6, 2025
1 parent 172a6b6 commit 497e7ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Binary file added episodes/data/covid_150days.rds
Binary file not shown.
Binary file added episodes/data/covid_300days.rds
Binary file not shown.
Binary file added episodes/data/covid_490days.rds
Binary file not shown.
49 changes: 49 additions & 0 deletions instructors/data-covid-filter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

library(tidyverse)
library(incidence2)

# read data ---------------------------------------------------------------

incidence_class <- incidence2::covidregionaldataUK %>%
as_tibble() %>%
filter(region == "London") %>%
# preprocess missing values
tidyr::replace_na(
list(
deaths_new = 0,
cases_new = 0
)
) %>%
# compute the daily incidence
incidence2::incidence(
date_index = "date",
counts = c("cases_new","deaths_new"),
date_names_to = "date",
complete_dates = TRUE
) %>%
identity()


incidence_class %>%
# filter(date < ymd(20200415)) %>%
# filter(date < ymd(20200701)) %>%
plot()

covid_incidence2 <- incidence_class %>%
cfr::prepare_data(
cases_variable = "cases_new",
deaths_variable = "deaths_new") %>%
as_tibble()

covid_incidence2

covid_incidence2 %>%
write_rds(file.path("episodes", "data", "covid_490days.rds"))

covid_incidence2 %>%
filter(date < ymd(20200415)) %>%
write_rds(file.path("episodes", "data", "covid_150days.rds"))

covid_incidence2 %>%
filter(date < ymd(20200701)) %>%
write_rds(file.path("episodes", "data", "covid_300days.rds"))

0 comments on commit 497e7ea

Please sign in to comment.