Skip to contents

plot method for preprocessed data of class "enw_preprocess_data". Creates descriptive plots of the empirical reporting delay distribution and notification time series.

Usage

# S3 method for class 'enw_preprocess_data'
plot(
  x,
  type = c("obs", "delay_cumulative", "delay_fraction", "delay_quantiles",
    "delay_counts"),
  delay_group_thresh = NULL,
  quantiles = c(0.1, 0.5, 0.9),
  log = FALSE,
  facet = TRUE,
  ...
)

Arguments

x

A preprocessed data object as produced by enw_preprocess_data().

type

Character string indicating the plot type; enforced by base::match.arg(). Options:

delay_group_thresh

A numeric vector of left-closed interval thresholds for delay grouping (use right = FALSE semantics, so the upper bound should exceed max_delay). Used by "delay_cumulative", "delay_fraction", and "delay_counts". Defaults to NULL, which auto-generates thresholds from max_delay.

quantiles

A numeric vector of probabilities for the "delay_quantiles" type. Defaults to c(0.1, 0.5, 0.9).

log

Logical, defaults to FALSE. Should counts be plotted on the log scale (only for "obs" type).

facet

Logical. When TRUE (the default), delay-based plots with more than one .group are automatically wrapped by group. Set to FALSE to disable and add a custom facet layer.

...

Additional arguments passed to the underlying plot function.

Value

A ggplot2 object.

Examples

pobs <- enw_example("preprocessed_observations")

# Latest observations
plot(pobs, type = "obs")


# Cumulative reporting delay
plot(pobs, type = "delay_cumulative")


# Reporting delay heatmap
plot(pobs, type = "delay_fraction")


# Reporting delay quantiles
plot(pobs, type = "delay_quantiles")


# Notifications by delay group
plot(pobs, type = "delay_counts")