powered by
This creates a simple wrapper around a function for use in map_xxx. Useful functions include scales and palettes from the scales package.
map_xxx
scales
by_function(inner_fn, ignore_na = TRUE)
A function for use in map_*** functions.
map_***
A one-argument function which maps cell values to property values.
If TRUE, NA values in the result will be left unchanged from their previous values. Otherwise, NA normally resets to the default.
TRUE
NA
The argument of inner_fn will be as.matrix(ht[row, col]). Be aware how matrix conversion affects the mode of cell data.
inner_fn
as.matrix(ht[row, col])
mode
mapping-functions
Other mapping functions: by_cases(), by_colorspace(), by_quantiles(), by_ranges(), by_regex(), by_rows(), by_values()
by_cases()
by_colorspace()
by_quantiles()
by_ranges()
by_regex()
by_rows()
by_values()
ht <- as_hux(matrix(runif(20), 5, 4)) map_background_color( ht, by_function(grey) ) if (requireNamespace("scales")) { map_text_color(ht, by_function( scales::seq_gradient_pal() )) }
Run the code above in your browser using DataLab