Last active
July 21, 2021 09:53
-
-
Save locklin/67e287b4c8593b6f3d91159a2b97d6a4 to your computer and use it in GitHub Desktop.
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
## 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