-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3af03ae
commit d32dce0
Showing
2 changed files
with
20,794 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.