Commit 1f0238a1 authored by Facundo Muñoz's avatar Facundo Muñoz ®️
Browse files

Clean-up covid data in plan.

parent 7accfd41
......@@ -114,13 +114,29 @@ Lock <- do.call(
})
)
## Sanity checks in covid
## there is exactly one record per country and date
# covid %>% group_by(date, name) %>% count() %>% pull(n) %>% identical(rep(1L, length(.))) # TRUE
## The population is consistent for each country
# covid %>%
# count(name, pop) %>%
# count(name, wt = 1L) %>%
# pull(n) %>%
# identical(rep(1L, length(.)))
deaths_by_ctry_dt <- covid %>%
filter(deaths >= 0) %>%
group_by(date, name) %>%
summarise(deaths = sum(deaths)) %>%
ungroup() %>%
summarise(deaths = sum(deaths), .groups = "drop") %>%
mutate(date = as.Date(date))
# identical(
# deaths_by_ctry_dt,
# covid %>%
# select(date, name, deaths) %>%
# mutate(date = as.Date(date)) %>%
# arrange(date, name)
# )
data_update_date <- format(Sys.Date() - 1,
"%d %b %Y")
......
......@@ -63,7 +63,10 @@ plan <- drake_plan(## raw_data = read_excel(
sdt = format(Sys.Date(),
"%d %b %Y"),
covid = ecdc_covid19(Sys.Date() - 1),
covid = ecdc_covid19(Sys.Date() - 1) %>%
# rm some negative records that are obvious errors
# should we use NA instead?
filter(deaths >= 0),
## ## String notice for data update
## data_update_date = format(Sys.Date() - 1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment