Skip to contents

Creates a histogram of surprise values.

Usage

geom_surprise_histogram(
  mapping = NULL,
  data = NULL,
  which = c("surprise", "signed_surprise"),
  bins = 30,
  fill = "#4575b4",
  color = "white",
  ...
)

Arguments

mapping

Aesthetic mapping

data

Data with surprise values

which

Which surprise to plot: "surprise" or "signed_surprise"

bins

Number of bins

fill

Fill color

color

Border color

...

Additional arguments passed to ggplot2::geom_histogram()

Value

A ggplot2 layer

Examples

library(ggplot2)
library(sf)

nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_surprise <- surprise(nc, observed = SID74, expected = BIR74)

ggplot(nc_surprise) +
  geom_surprise_histogram()