by_colorspace {huxtable} | R Documentation |
Map numeric cell contents smoothly to colors
Description
by_colorspace()
can be used to set background, border or
text colors, visually differentiating high or low values.
Usage
by_colorspace(
...,
range = NULL,
na_color = NA,
ignore_na = TRUE,
colwise = FALSE
)
Arguments
... |
Colors |
range |
Numeric endpoints. If |
na_color |
Color to return for |
ignore_na |
If |
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
Other mapping functions:
by_cases()
,
by_function()
,
by_quantiles()
,
by_ranges()
,
by_regex()
,
by_rows()
,
by_values()
Examples
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))
[Package huxtable version 5.5.6 Index]