by_ranges() sets property values for cells falling within different numeric ranges.
Arguments
- breaks
A vector of numbers in increasing order.
- values
A vector of property values.
length(values)should be one greater thanlength(breaks)ifextend = TRUE, or one less ifextend = FALSE.- right
If
TRUE, intervals are closed on the right, i.e. if values are exactly equal to abreak, they go in the lower group. Otherwise, intervals are closed on the left, so equal values go in the higher group.FALSEby default.- extend
Extend
breakstoc(-Inf, breaks, Inf), i.e. include numbers below and above the outermost breaks.TRUEby default.- ignore_na
If
TRUE,NAvalues in the result will be left unchanged from their previous values. Otherwise,NAnormally resets to the default.
See also
Other mapping functions:
by_cases(),
by_colorspace(),
by_function(),
by_quantiles(),
by_regex(),
by_rows(),
by_values()
Examples
ht <- huxtable(c(1, 3, 5))
map_background_color(
ht,
by_ranges(
c(2, 4),
c("red", "yellow", "blue")
)
)
#> 1
#> 3
#> 5
map_background_color(
ht,
by_ranges(
c(2, 4),
"pink",
extend = FALSE
)
)
#> 1
#> 3
#> 5
map_background_color(
ht,
by_ranges(
c(1, 5),
c("red", "yellow", "green"),
right = TRUE
)
)
#> 1
#> 3
#> 5
map_background_color(
ht,
by_ranges(
c(1, 5),
c("red", "yellow", "green"),
right = FALSE
)
)
#> 1
#> 3
#> 5