color_lgl | R Documentation |
color_lgl()
takes a vector of R or hex colors and performs logical tests
on RGB values (r, g, and/or b) and/or HSV values (h, s, and v) supplied in the form
of logial expressions (see Examples).
color_lgl(color_vec, ...)
color_vec |
A vector of hex or R colors. |
test |
A logical test to perform on the set of colors |
a logical vector indicating which members of the color vector pass the test(s)
color_vec <- c("#FF0000","dodgerblue","orange","808080","#000000")
# Which colors have an R value > 0.5 in RGB space (scaled between 0 and 1)?
color_lgl(color_vec,
r > 0.5)
# Which colors have R or B > 0.3 in RGB space?
color_lgl(color_vec,
r > 0.3 | g > 0.3)
# Which colors are highly saturated (S > 0.8 in HSV space)?
color_lgl(color_vec,
s > 0.8)
# Which colors are dark (low V in HSV space)?
color_lgl(color_vec,
v < 0.2)
# Which colors are bright, saturated red?
color_lgl(color_vec,
r > 0.7 & s > 0.7 & v > 0.7)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.