-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcess.r
More file actions
22 lines (14 loc) · 784 Bytes
/
Copy pathexcess.r
File metadata and controls
22 lines (14 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
data <- read.csv("excess.csv")
popTable <- read.csv("nst-est2019-alldata.csv")
library(dplyr)
library(rbenchmark)
benchmark("r" = {
data$Excess <- data$ObservedNumber - data$AverageExpectedCount
data$WeekEndingDate <- as.Date(data$WeekEndingDate, format="%Y-%m-%d")
excessTable <- data |> filter(Type=='Unweighted' & Outcome=='Allcauses' & WeekEndingDate < '2021-11-13' & WeekEndingDate > '2020-03-13') |> group_by(State) |> summarise(Excess = sum(Excess))
joined <- merge(x = excessTable, y = popTable, by.x = 'State', by.y = 'NAME')
joined$ExcessPP <- joined$Excess / joined$POPESTIMATE2019
select(joined, State, ExcessPP) |> arrange(desc(ExcessPP))
},
replications=100
)