TheEconomist / covid-19-excess-deaths-tracker

Source code and data for The Economist's covid-19 excess deaths tracker
https://www.economist.com/graphic-detail/coronavirus-excess-deaths-tracker
641 stars 163 forks source link

Australia and ISO-8601 #17

Closed ghost closed 3 years ago

ghost commented 3 years ago

Assuming that Australia data (WMD or HMD - SMTF) adopted ISO-8601, should the code (below) in cleaning_script align with it,

# Group covid deaths by week
australia_weekly_covid_deaths <- global_covid_source_latest %>%
  filter(date >= as.Date("2020-01-01")) %>%
  mutate(week_date = date,
         week = week(week_date),
         year = year(week_date),
         covid_deaths = Australia) %>%
  dplyr::select(date,year,week,covid_deaths) %>%
  group_by(year,week) %>%
  summarise(covid_deaths = sum(covid_deaths, na.rm=T)) %>%
  drop_na()

and change to something like,

# Group covid deaths by week
australia_weekly_covid_deaths <- global_covid_source_latest %>%
  filter(date >= as.Date("2020-01-01")) %>%
  mutate(week_date = date,
         week = isoweek(week_date),
         year = isoyear(week_date),
         covid_deaths = Australia) %>%
  dplyr::select(date,year,week,covid_deaths) %>%
  group_by(year,week) %>%
  summarise(covid_deaths = sum(covid_deaths, na.rm=T)) %>%
  drop_na()

or

australia_weekly_covid_deaths <- global_covid_source_latest %>%
  filter(date >= as.Date("2020-01-01")) %>%
  mutate(week = as.numeric(str_sub(aweek::date2week(date,week_start=1),7,8)),
         year = as.numeric(str_sub(aweek::date2week(date,week_start=1),1,4)),
         covid_deaths = Australia) %>%
  dplyr::select(date,year,week,covid_deaths) %>%
  group_by(year,week) %>%
  summarise(covid_deaths = sum(covid_deaths, na.rm=T)) %>%
  drop_na()
sondreus commented 3 years ago

Now fixed, thanks for spotting and reporting the issue.