Fills a column or columns of a data frame using a discrete colour palette, based on an expression.
rule_fill_discrete(
x,
columns,
expression,
colours = NA,
na.value = "#FFFFFF",
h = c(0, 360) + 15,
c = 100,
l = 65,
h.start = 0,
direction = 1,
lockcells = FALSE
)
A condformat object, typically created with condformat()
A character vector with column names to be coloured. Optionally
tidyselect::language()
can be used.
an expression to be evaluated with the data. It should evaluate to a logical or an integer vector, that will be used to determine which cells are to be coloured.
a character vector with colours as values and the expression possible results as names.
a character string with the CSS color to be used in missing values
range of hues to use, in [0, 360]
chroma (intensity of colour), maximum value varies depending on combination of hue and luminance.
luminance (lightness), in [0, 100]
hue to start at
direction to travel around the colour wheel, 1 = clockwise, -1 = counter-clockwise
logical value determining if no further rules should be applied to the affected cells.
The condformat_tbl object, with the added formatting information
Other rule:
rule_css()
,
rule_fill_bar()
,
rule_fill_gradient2()
,
rule_fill_gradient()
,
rule_text_bold()
,
rule_text_color()
data(iris)
cf <- condformat(iris[c(1:5, 70:75, 120:125), ]) %>%
rule_fill_discrete("Species", colours = c("setosa" = "red",
"versicolor" = "blue",
"virginica" = "green")) %>%
rule_fill_discrete("Sepal.Length", expression = Sepal.Length > 4.6,
colours=c("TRUE"="red"))
if (FALSE) {
print(cf)
}
cf <- condformat(iris[c(1:5, 70:75, 120:125), ]) %>%
rule_fill_discrete(c(starts_with("Sepal"), starts_with("Petal")),
expression = Sepal.Length > 4.6,
colours=c("TRUE"="red"))
if (FALSE) {
print(cf)
}