if (FALSE) { # requireNamespace("outbreaks") && requireNamespace("ggplot2")
# use simulated linelist data from the outbreaks package
linelist <- outbreaks::ebola_sim_clean$linelist
x <- as_isoweek(linelist$date_of_infection)
dat <- aggregate(list(cases = x), by = list(week = x), FUN = length)
# plot the output
(week_plot <-
ggplot2::ggplot(dat, ggplot2::aes(week, cases)) +
ggplot2::geom_col(width = 1, colour = "white") +
ggplot2::theme_bw())
# We can have non-centred date labels on the x_axis by using the
# associated scale function and explicitly specifying a format for
# the date labels:
week_plot + scale_x_grates_isoweek(format = "%Y-%m-%d")
}
Run the code above in your browser using DataLab