Skip to content

Instantly share code, notes, and snippets.

@locklin
Last active July 21, 2021 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save locklin/67e287b4c8593b6f3d91159a2b97d6a4 to your computer and use it in GitHub Desktop.
Save locklin/67e287b4c8593b6f3d91159a2b97d6a4 to your computer and use it in GitHub Desktop.
## install.packages("MMWRweek")
require("MMWRweek")
require(xts)
require(timeDate)
read.csv("https://www.cdc.gov/flu/weekly/weeklyarchives2020-2021/data/NCHSData19.csv") -> data2021
pnts <- xts(data2021$All.Deaths ,as.timeDate(MMWRweek2Date(data2021$Year,data2021$Week)) + 7 * 24 * 3600)
mean(apply.yearly(pnts["::2019"],sum)) ## mean deaths of recent pre-rona years
years <- apply.yearly(pnts,sum) ## deaths each year
plot(pnts) ## you can see the peaks
as.numeric(years[8]) - last(apply.yearly(pnts["::2019"],sum)) ## use last year for simplicity sake
## 499770 yeah, close enough for govt work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment