View source: R/rule_fill_discrete.R
| rule_fill_discrete | R Documentation | 
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
)
| x | A condformat object, typically created with  | 
| columns | A character vector with column names to be coloured. Optionally
 | 
| expression | 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. | 
| colours | a character vector with colours as values and the expression possible results as names. | 
| na.value | a character string with the CSS color to be used in missing values | 
| h | range of hues to use, in [0, 360] | 
| c | chroma (intensity of colour), maximum value varies depending on combination of hue and luminance. | 
| l | luminance (lightness), in [0, 100] | 
| h.start | hue to start at | 
| direction | direction to travel around the colour wheel, 1 = clockwise, -1 = counter-clockwise | 
| lockcells | 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"))
## Not run: 
print(cf)
## End(Not run)
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"))
## Not run: 
print(cf)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.