Apply a CSS style property as a conditional formatting rule

rule_css(x, columns, expression, css_field, na.value = "", lockcells = FALSE)

Arguments

x

A condformat object, typically created with condformat()

columns

A character vector with column names to be coloured. Optionally tidyselect::language() can be used.

expression

This expression should evaluate to an array of the values

css_field

CSS style property name (e.g. "color")

na.value

CSS property value to be used in missing values (e.g. "grey")

lockcells

logical value determining if no further rules should be applied to the affected cells.

Examples

data(iris)
cf <- condformat(iris[c(1:5, 51:55, 101:105),]) %>%
  rule_css(Species, expression = ifelse(Species == "setosa", "red", "darkgreen"),
           css_field = "color")
if (FALSE) {
print(cf)
}