EpiCurves: epicurves in ggplot with ggsurveillance"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE,
  fig.width = 7,
  fig.height = 4
)
library(ggplot2)
library(dplyr)
library(tidyr)
library(outbreaks)
library(ggsurveillance)

Epi Curve examples

This vignette is still work in progress. But the examples are hopefully already helpful and inspiring.

Ebola Outbreak in Kikwit, Democratic Republic of the Congo 1995

ggplot(outbreaks::ebola_kikwit_1995, aes(x = date, weight = onset)) +
  geom_epicurve(date_resolution = "week") +
  scale_x_date(date_breaks = "2 weeks", date_labels = "%V'%g", name = "week") +
  scale_y_cases_5er() +
  theme_bw()

SARS Outbreak in Canada 2003

outbreaks::sars_canada_2003 |>
  pivot_longer(starts_with("cases"), names_prefix = "cases_", names_to = "origin") |>
  ggplot(aes(x = date, weight = value, fill = origin)) +
  geom_epicurve(date_resolution = "week") +
  scale_y_cases_5er() +
  theme_bw()

Influenza Data from Germany 2020-2025

influenza_germany |>
  # Keep Age Groups 00-14, 15-59, 60+
  filter(AgeGroup != "00+") |>
  # Calc Influenza Seasons
  align_dates_seasonal(dates_from = ReportingWeek) |>
  ggplot(aes(x = ReportingWeek, weight = Cases, fill = season)) + # , weight = Cases
  geom_vline_year(color = "grey50") +
  geom_epicurve(color = NA, stat = "bin_date", date_resolution = "week") +
  scale_y_cases_5er() +
  theme_bw()

Extra

influenza_germany |>
  # Calc Influenza Seasons
  align_dates_seasonal(dates_from = ReportingWeek) |>
  ggplot(aes(x = ReportingWeek, weight = Cases, color = AgeGroup)) + # , weight = Cases
  geom_line(stat = "bin_date", date_resolution = "month") +
  scale_y_cases_5er() +
  facet_wrap(~AgeGroup) +
  theme_bw()


Try the ggsurveillance package in your browser

Any scripts or data that you put into this service are public.

ggsurveillance documentation built on April 12, 2025, 1:09 a.m.