epicurve: Draw a classic style epidemic curve (with rectangles)

View source: R/epicurve.R

epicurveR Documentation

Draw a classic style epidemic curve (with rectangles)

Description

epikml() takes a set of coordinates and other associated info as input, and creates a KML (Keyhole Markup Language) file that can be opened with Google Earth or other similar programs. It's original intention was to plot disease cases, but can find wider use as well.

Usage

epicurve(
  x,
  series = NA,
  col = "green",
  xlim = range(x, na.rm = TRUE) + xmargin * c(-1, 1),
  ymax = NA,
  xlab = NA,
  ylab = NA,
  xaxt = "s",
  yaxt = "s",
  box = FALSE,
  xmargin = 2
)

Arguments

x

Data vector of integers or 'Date' objects

series

Factor of equal length as x, used to group cases and color them separately

col

Color, or vector of colors of length equal to the levels of series.

xlim

Limits for the x axis. Defaults to the range of x, plus/minus xmargin

ymax

Maximum for the y axis. Leaving NA (the default) will calculate it automatically. Specify it manually if needed (for example, to create a slideshow of epicurves to be shown in succession).

xlab

Title for x axis

ylab

Title for y axis

xaxt

x axis type. Specifying xaxt="n" suppresses plotting of the x axis. You can then draw it explicitly with link{axis}.

yaxt

y axis type. Specifying yaxt="n" suppresses plotting of the y axis. You can then draw it explicitly with link{axis}.

box

If FALSE, rectangles are drawn with the appropriate aspect ratio to fit the range of both axes. If TRUE, the function adjusts the length of the y axis so that squares are drawn

xmargin

When drawing the x axis and the limits are not explicitly set, extend the range of x by this amount and use that as the limits of the x axis.

Details

Scales are NOT drawn for either axis. Use axis to draw them explicitly to your liking.

Value

Nothing. The function plots the epidemic curve on the current graphics device.

Examples

# Create some dummy data
sampdates <- seq(as.Date("2016-07-15"), as.Date("2016-09-15"), 1)
x <- sample(sampdates, 120, rep=TRUE)
gender <- sample(c("Male","Female"), 120, rep=TRUE)

# Draw the epidemic curve
epicurve(x, gender, c("skyblue","pink"))


thlytras/Rivets documentation built on April 16, 2024, 5:43 a.m.