Skip to contents

Stat for Surprise with sf Geometries

Usage

stat_surprise_sf(
  mapping = NULL,
  data = NULL,
  geom = ggplot2::GeomSf,
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  models = c("uniform", "baserate", "funnel"),
  signed = TRUE,
  ...
)

Arguments

mapping

Aesthetic mapping created by ggplot2::aes(). Required aesthetics are geometry (from sf) and observed. Optional aesthetics include expected and sample_size.

data

Data (typically an sf object)

geom

Geometry to use (default: "sf")

position

Position adjustment

na.rm

Remove NA values?

show.legend

Show legend?

inherit.aes

Inherit aesthetics from ggplot?

models

Character vector of model types to use. Options: "uniform", "baserate", "gaussian", "sampled", "funnel"

signed

Logical; compute signed surprise?

...

Additional arguments passed to the layer

Value

A list containing a ggplot2 layer using StatSurpriseSf and ggplot2::coord_sf(). The stat computes surprise and, when signed = TRUE, signed_surprise, which are available to downstream geoms via after_stat().