Fill column with divergent colour gradient

Description

Fills the background color of a column using a three colors gradient based on the values by an expression

Usage

1
2
3
4
5
6
7
8
rule_fill_gradient2(..., expression, low = scales::muted("red"),
  mid = "white", high = scales::muted("blue"), midpoint = NA,
  space = "Lab", na.value = "#7F7F7F", limits = NA, lockcells = FALSE)

rule_fill_gradient2_(columns, expression, low = scales::muted("red"),
  mid = "white", high = scales::muted("blue"), midpoint = NA,
  space = "Lab", na.value = "#7F7F7F", limits = NA, lockcells = FALSE,
  env = parent.frame())

Arguments

...

Comma separated list of unquoted column names. If expression is also given, then this list can use any of the select syntax possibilities.

expression

An expression to be evaluated with the data frame this rule applies to. It should evaluate to a numeric vector, that will be used to compute the color gradient values. In rule_fill_gradient_, a character string.

low

colour for low end of gradient.

mid

colour for mid point

high

colour for high end of gradient.

midpoint

the value used for the middle color (the median by default)

space

colour space in which to calculate gradient. Must be "Lab" - other values are deprecated.

na.value

fill color for missing values

limits

range of limits that the gradient should cover

lockcells

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

columns

[SE] a character vector with the column names (Only in rule_fill_gradient2_)

env

[SE] the environment where 'expression' is to be evaluated (Only in rule_fill_gradient2_)

Value

The condformat_tbl object, with the added formatting information

See Also

Other rule: rule_fill_discrete, rule_fill_gradient

Other rule: rule_fill_discrete, rule_fill_gradient

Examples

1
2
3
4
5
6
7
data(iris)
condformat(iris[c(1:5, 70:75, 120:125), ]) +
 rule_fill_gradient2(Sepal.Length) +
 rule_fill_gradient2(Species, expression=Sepal.Length - Sepal.Width)
data(iris)
condformat(iris) + rule_fill_gradient2_(columns=c("Sepal.Length"))
condformat(iris) + rule_fill_gradient2_("Species", expression="Sepal.Length-Sepal.Width")