by_colorspace: Map numeric cell contents smoothly to colors

Description Usage Arguments Details Value See Also Examples

Description

Map numeric cell contents smoothly to colors

Usage

1
2
3
4
5
6
7
by_colorspace(
  ...,
  range = NULL,
  na_color = NA,
  ignore_na = TRUE,
  colwise = FALSE
)

Arguments

...

Colors

range

Numeric endpoints. If NULL, these are determined from the data.

na_color

Color to return for NA values. Can be NA itself.

ignore_na

If TRUE, NA values in the result will be left unchanged from their previous values. Otherwise, NA normally resets to the default.

colwise

Logical. Calculate breaks separately within each column?

Details

by_colorspace requires the "scales" package.

Value

A function for use in map_*** functions.

See Also

mapping-functions

Other mapping functions: by_cases(), by_function(), by_quantiles(), by_ranges(), by_regex(), by_rows(), by_values()

Examples

1
2
3
4
5
6
7
8
9
if (! requireNamespace("scales")) {
  stop("Please install the \"scales\" package to run this example")
}
ht <- as_hux(matrix(rnorm(25), 5, 5))
map_background_color(ht,
      by_colorspace("red", "yellow", "blue"))
map_background_color(ht,
      by_colorspace("red", "yellow", "blue",
        colwise = TRUE))

huxtable documentation built on Feb. 15, 2021, 1:07 a.m.