timriffe / covid_age

COVerAGE-DB: COVID-19 cases, deaths, and tests by age and sex
Other
56 stars 30 forks source link

Cases for USA is lost #141

Closed liuyanguu closed 2 years ago

liuyanguu commented 2 years ago
library(covidAgeData)
library(data.table)
dt5_ori <- download_covid(data = "Output_5", temp = TRUE,
                          verbose = FALSE, progress = FALSE, return = "data.table")
# Only Deaths
dt5_ori[Country %like% "USA" & Region == "All" & Sex == "b" & Date == "19.03.2022",]
dt5_ori[Country %like% "USA" & Sex == "b" & Date == "19.03.2022",]

image

timriffe commented 2 years ago

Hi, a new version was just uploaded. Note however that if a filter is restricted to a particular date that there may or may not be an observation, best rather to try a filter such as:

dt5_ori[Country %like% "USA" & Region == "All" & Sex == "b" & !is.na(Cases)] %>% filter(dmy(Date) == max(dmy(Date)))

Sorry there's probably a way to pipe to a secondary data.table filter operation, but I didn't look it up, but you get the idea. Sometimes a population has time series for different measures on the dates that are close but don't coincide. For those cases, it is recommended to interpolate to be able to match dates.

liuyanguu commented 2 years ago

Many thanks for the quick reply! Looks good now. When I actually filter the date I melt "Cases" and "Deaths" into "Measure" first and then filter max date by measure so it's not a problem. But many thanks for the heads-up!