rule_fill_discrete: Fill column with discrete colors

Description Usage Arguments Value See Also Examples

View source: R/rule_fill_discrete.R

Description

Fills a column or columns of a data frame using a discrete colour palette, based on an expression.

Usage

1
2
3
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)

Arguments

x

A condformat object, typically created with condformat()

columns

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

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.

Value

The condformat_tbl object, with the added formatting information

See Also

Other rule: rule_css, rule_fill_bar, rule_fill_gradient2, rule_fill_gradient, rule_text_bold, rule_text_color

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(iris)
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"))

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"))

zeehio/condformat documentation built on Nov. 16, 2018, 5:05 a.m.