View source: R/epiweek-scale.R
scale_x_grates_epiweek | R Documentation |
ggplot2 scale for an <grates_epiweek>
vector.
scale_x_grates_epiweek(
...,
breaks = ggplot2::waiver(),
n.breaks = 6L,
format = NULL
)
... |
Not currently used. |
breaks |
A |
n.breaks |
Approximate number of breaks calculated using Will only have an effect if |
format |
Format to use if "Date" scales are required. If NULL (default) then labels are in the standard epiweek format (YYYY-Www). If "week" then the labels are of the form Www (e.g. W37). Otherwise the value is used by |
A scale for use with ggplot2.
# use simulated linelist data from the outbreaks package
linelist <- outbreaks::ebola_sim_clean$linelist
x <- as_epiweek(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_epiweek(format = "%Y-%m-%d")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.