Skip to content

Commit

Permalink
Add covid data as CSV, fixes #71
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Aug 11, 2023
1 parent 3af03ae commit d32dce0
Show file tree
Hide file tree
Showing 2 changed files with 20,794 additions and 24 deletions.
31 changes: 7 additions & 24 deletions data-raw/covid_data.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
## code to prepare `covid_data` dataset goes here

library(dplyr)

# get data from covidregionaldata
covid_data <- covidregionaldata::get_national_data(
source = "who", verbose = FALSE
covid_data <- read.csv(
system.file(
"extdata", "covid_data.csv",
package = "cfr",
mustWork = TRUE
)
)

# rename columns
covid_data <- rename(covid_data, cases = cases_new, deaths = deaths_new)

# get countries with >= 100,000 deaths over the first three
# years of the pandemic, 2020, 2021, and 2022
covid_data <- covid_data %>%
filter(date < "2023-01-01") %>%
group_by(iso_code) %>%
mutate(total_deaths = max(deaths_total)) %>%
filter(total_deaths > 100000 & !is.na(country)) %>%
ungroup()

# select columns
covid_data <- covid_data %>%
select(date, country, cases, deaths)

# convert to data.frame
covid_data <- as.data.frame(covid_data)
covid_data$date <- as.Date(covid_data$date)

usethis::use_data(covid_data, overwrite = TRUE)
Loading

0 comments on commit d32dce0

Please sign in to comment.