set.seed(123)
dat <- rpois(n = 50, lambda = 2)
edr.04 <- epi.edr(dat, n = 4, conf.level = 0.95, nsim = 99, na.zero = TRUE)
sdate <- as.Date(x = "31/12/2015", format = "%d/%m/%Y")
dat.04 <- data.frame(idate = sdate + 1:50, est = edr.04$est,
low = edr.04$lower, upp = edr.04$upper)
## Line plot of EDR (and its 95% confidence interval) as a function of
## calendar time:
library(ggplot2)
ggplot(dat.04, aes(x = as.integer(idate), y = est)) +
geom_line() +
geom_line(dat = dat.04, aes(x = as.integer(idate), y = upp),
lty = 3, size = 0.5) +
geom_line(dat = dat.04, aes(x = as.integer(idate), y = low),
lty = 3, size = 0.5) +
scale_x_continuous(name = "Date",
breaks = seq(from = min(as.integer(dat.04$idate)),
to = max(as.integer(dat.04$idate)), by = 7),
labels = seq(from = min(dat.04$idate),
to = max(dat.04$idate), by = 7),
limits = c(min(as.integer(dat.04$idate)),
max(as.integer(dat.04$idate)))) +
scale_y_continuous(name = "Estimated disemination ratio (EDR)",
limits = c(0,10)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, size = 10)) +
geom_hline(yintercept = 1, lty = 2)
Run the code above in your browser using DataLab