Skip to contents

Conveniently maps data values to icons for use in magicIcons(), analogous to leaflet::colorFactor(), leaflet::colorBin() and leaflet::colorQuantile(). Icons are, by their nature, discrete, so there is no analogue to leaflet::colorNumeric(). For leaflet::colorBin() and leaflet::colorQuantile(), it would make sense to pick "ordered" icons such as the "hourglass" or "temperature" icon families in Font Awesome.

Usage

iconFactor(icons, domain, na.icon = "question")

iconBin(
  icons,
  domain,
  bins = length(icons),
  na.icon = "question",
  right = FALSE
)

iconQuantile(
  icons,
  domain,
  n = length(icons),
  probs = seq(0, 1, length.out = n + 1),
  na.icon = "question",
  right = FALSE
)

Arguments

icons

The icons that values will be mapped to. Note that the library (e.g., "fontawesome") is defined in magicIcons().

domain

The possible values that can be mapped. For iconFactor() this should be categorical data. For iconBin() and iconQuantile()

na.icon

The icon to return for missing or out-of-scope values.

bins, right

Passed to cut().

n

Number of equal-size quantiles desired. For more precise control, use the probs argument instead.

probs

A more precise alternative to probs. Passed directly to quantile().

Value

A function that takes a single parameter, x; when called with a vector of factors/characters (for iconFactor()) or numbers (for iconBin() and iconQuantile()), icon names are returned.