library(dplyr)
df <- data.frame(indicatorid = rep(c(1234, 5678, 91011, 121314),
each = 19 * 2 * 5),
year = rep(2006:2010, each = 19 * 2),
sex = rep(rep(c("Male", "Female"), each = 19), 5),
ageband = rep(c(0,5,10,15,20,25,30,35,40,45,
50,55,60,65,70,75,80,85,90), times = 10),
obs = sample(200, 19 * 2 * 5 * 4, replace = TRUE),
pop = sample(10000:20000, 19 * 2 * 5 * 4, replace = TRUE))
## default execution
df %>%
group_by(indicatorid, year, sex) %>%
phe_dsr(obs, pop)
## calculate both 95% and 99.8% CIs in single execution
df %>%
group_by(indicatorid, year, sex) %>%
phe_dsr(obs, pop, confidence = c(0.95, 0.998))
## calculate DSRs for multiple grouping sets in single execution
df %>%
group_by(indicatorid, year, sex) %>%
phe_dsr(obs, pop, type = "standard")
Run the code above in your browser using DataLab