Skip to content

Instantly share code, notes, and snippets.

@locklin

locklin/cdc.R Secret

Created May 1, 2022 11:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save locklin/94b7f758ece1ea347fcd000e308545cd to your computer and use it in GitHub Desktop.
Save locklin/94b7f758ece1ea347fcd000e308545cd to your computer and use it in GitHub Desktop.
dumb 'rona calculation
## install.packages("MMWRweek")
require("MMWRweek")
require(xts)
require(timeDate)
## May 1 2022
read.csv("https://www.cdc.gov/flu/weekly/weeklyarchives2021-2022/data/NCHSData16.csv") -> data2022
pnts <- xts(data2022$All.Deaths ,as.timeDate(MMWRweek2Date(data2022$Year,data2022$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
years.adj <- years
years.adj[10] = last(years.adj)*52/16 ## naively adjusted 2022
plot(pnts) ## you can see the peaks
as.numeric(years[8]) - last(apply.yearly(pnts["::2019"],sum))
as.numeric(years[9]) - last(apply.yearly(pnts["::2019"],sum))
as.numeric(years.adj[10]) - last(apply.yearly(pnts["::2019"],sum))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment