plot.incidence2 {incidence2}R Documentation

Plot an incidence object

Description

plot() can be used to provide a bar plot of an incidence object. Due to the complexities with automating plotting it is some what experimental in nature and it may be better to use ggplot2 directly.

Usage

## S3 method for class 'incidence2'
plot(
  x,
  y,
  width = 1,
  colour_palette = vibrant,
  border_colour = NA,
  na_colour = "grey",
  alpha = 0.7,
  fill = NULL,
  legend = c("right", "left", "bottom", "top", "none"),
  title = NULL,
  angle = 0,
  size = NULL,
  nrow = NULL,
  n_breaks = 6L,
  show_cases = FALSE,
  ...
)

Arguments

x

incidence2 object.

y

Not used.

Required for compatibility with the plot() generic.

width

numeric.

Value between 0 and 1 indicating the relative size of the bars to the interval.

Default 1.

colour_palette

function.

The color palette to be used for the different count variables.

Defaults to vibrant (see ?palettes).

border_colour

character.

The color to be used for the borders of the bars.

Use NA (default) for invisible borders.

na_colour

character.

The colour to plot NA values in graphs.

Defaults to grey.

alpha

numeric.

The alpha level for color transparency, with 1 being fully opaque and 0 fully transparent

Defaults to 0.7.

fill

character.

Which variable to colour plots by.

Must be a group or count variable and will mean that variable is not used for facetting.

If NULL no distinction if made for plot colours.

legend

character.

Position of legend in plot.

Only applied if fill is not NULL.

One of "right" (default), "left", "bottom", "top" or "none".

title

character.

Optional title for the graph.

angle

numeric.

Rotation angle for text.

size

numeric.

text size in pts.

nrow

integer.

Number of rows used for facetting if there are group variables present and just one count in the incidence object.

Numeric values are coerced to integer via as.integer().

n_breaks

integer.

Approximate number of breaks calculated using scales::breaks_pretty().

Numeric values are coerced to integer via as.integer().

Default 6L.

show_cases

logical.

if TRUE, then each observation will be shown individually in a square format.

Normally only used for outbreaks with a small number of cases.

Defaults to FALSE.

...

Not currently used.

Details

Value

Examples


if (requireNamespace("outbreaks", quietly = TRUE) && requireNamespace("ggplot2", quietly = TRUE)) {
    data(ebola_sim_clean, package = "outbreaks")
    dat <- ebola_sim_clean$linelist

    inci <- incidence(dat, date_index = "date_of_onset", groups = "hospital")
    plot(inci, angle = 45)

    inci2 <- regroup(inci)
    plot(inci2)
}



[Package incidence2 version 2.3.1 Index]