Learn R Programming

incidence (version 1.2.1)

plot.incidence: Plot function for incidence objects

Description

This function is used to visualise the output of the incidence function, using the package ggplot2.

Usage

# S3 method for incidence
plot(x, ..., fit = NULL, stack = is.null(fit),
  color = "black", border = NA, col_pal = pal1, alpha = 0.7,
  xlab = "", ylab = NULL, labels_iso_week = !is.null(x$isoweeks))

Arguments

x

An incidence object, generated by the function incidence.

...

Further arguments passed to other methods (currently not used).

fit

An 'incidence_fit' objet as returned by fit.

stack

A logical indicating if bars of multiple groups should be stacked, or displayed side-by-side.

color

The color to be used for the filling of the bars; NA for invisiable bars; defaults to "black".

border

The color to be used for the borders of the bars; NA for invisiable borders; defaults to NA.

col_pal

The color palette to be used for the groups; defaults to pal1. See pal1 for other palettes implemented in incidence.

alpha

The alpha level for color transparency, with 1 being fully opaque and 0 fully transparent; defaults to 0.7.

xlab

The label to be used for the x-axis; empty by default.

ylab

The label to be used for the y-axis; by default, a label will be generated automatically according to the time interval used in incidence computation.

labels_iso_week

a logical value indicating whether labels x axis tick marks are in ISO 8601 week format yyyy-Www when plotting ISO week-based weekly incidence; defaults to be TRUE.

See Also

The incidence function to generate the 'incidence' objects.

Examples

Run this code
# NOT RUN {
if(require(outbreaks)) {
  onset <- ebola_sim$linelist$date_of_onset

  ## daily incidence
  inc <- incidence(onset)
  inc
  plot(inc)

  ## weekly incidence
  inc.week <- incidence(onset, interval = 7)
  inc.week
  plot(inc.week) # default to label x axis tick marks with isoweeks
  plot(inc.week, labels_iso_week = FALSE) # label x axis tick marks with dates
  plot(inc.week, border = "white") # with visible border

  ## use group information
  sex <- ebola_sim$linelist$gender
  inc.week.gender <- incidence(onset, interval = 7, groups = sex)
  plot(inc.week.gender)
  plot(inc.week.gender, labels_iso_week = FALSE)

  ## adding fit
  fit <- fit_optim_split(inc.week.gender)$fit
  plot(inc.week.gender, fit = fit)
  plot(inc.week.gender, fit = fit, labels_iso_week = FALSE)
}

# }

Run the code above in your browser using DataLab