Skip to contents

Convert percentiles to color names

Usage

pctile2color(
  x,
  colorbins = ejscreen_color_defaults("ejscreen")$colorbins,
  colorfills = ejscreen_color_defaults("ejscreen")$colorfills
)

Arguments

x

Numeric vector of percentiles on a 0-100 scale.

colorbins

Strictly increasing interior cutoffs, excluding 0 and 100.

colorfills

Vector of colors of length length(colorbins) + 1.

Value

Character vector of colors, as long as x. Missing and out-of-range percentiles return NA_character_.

Details

Alias for calc_ejscreen_map_color(), including its historical eleven-bin defaults. Both percentile schemes use the same four colors.

Examples

EJAM:::pctile2color(c(79, 80, 90, 95, 100, NA))
# gray, yellow, orange, red, red, NA
defaults <- EJAM:::ejscreen_color_defaults()
EJAM:::pctile2color(c(79, 80, 90, 95),
  colorbins = defaults$colorbins, colorfills = defaults$colorfills)