## toy example
incidence(c(1, 5, 8, 3, 7, 2, 4, 6, 9, 2))
incidence(c(1, 5, 8, 3, 7, 2, 4, 6, 9, 2), 2)
## example using simulated dataset
if(require(outbreaks)) { withAutoprint({
onset <- outbreaks::ebola_sim$linelist$date_of_onset
## daily incidence
inc <- incidence(onset)
inc
plot(inc)
## weekly incidence
inc.week <- incidence(onset, interval = 7, standard = FALSE)
inc.week
plot(inc.week)
plot(inc.week, border = "white") # with visible border
# Starting on Monday
inc.isoweek <- incidence(onset, interval = "isoweek")
inc.isoweek
# Starting on Sunday
inc.epiweek <- incidence(onset, interval = "epiweek")
inc.epiweek
# Starting on Saturday
inc.epiweek <- incidence(onset, interval = "saturday epiweek")
inc.epiweek
## use group information
sex <- outbreaks::ebola_sim$linelist$gender
inc.week.gender <- incidence(onset, interval = 7,
groups = sex, standard = FALSE)
inc.week.gender
head(inc.week.gender$counts)
plot(inc.week.gender, border = "grey90")
inc.satweek.gender <- incidence(onset, interval = "2 epiweeks: saturday",
groups = sex)
inc.satweek.gender
plot(inc.satweek.gender, border = "grey90")
})}
# Use of first_date
d <- Sys.Date() + sample(-3:10, 10, replace = TRUE)
# `standard` specified, no warning
di <- incidence(d, interval = "week", first_date = Sys.Date() - 10, standard = TRUE)
# warning issued if `standard` not specified
di <- incidence(d, interval = "week", first_date = Sys.Date() - 10)
# second instance: no warning issued
di <- incidence(d, interval = "week", first_date = Sys.Date() - 10)
Run the code above in your browser using DataLab