scale_col: Create a scale color for a html style attribute

Description Usage Arguments Value Examples

View source: R/colorize.r

Description

Designed to be used together with the attr_style function. The return value can directly be used to set the color in an html tag attribute (e.g., color, background-color)

Usage

1
scale_col(value, alpha = 1, col_range = c("red", "blue"))

Arguments

value

A numeric vector with values between -1 and 1. Determines the color mixture of the scale colors specified in col_range

alpha

Optionally, the alpha (transparency) can be specified, with 0 being fully transparent and 1 being fully colored. This can be a vector to specify a different alpha for each value.

col_range

The colors used in the scale.

Value

The string used to specify a color in a html tag attribute

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
scale_col(c(NA, -1, 0, 0.5, 1))

## used in combination with attr_style()
attr_style(color = scale_col(c(NA, -1, 0, 0.5, 1)))

## note that for background-color you need inversed
## quotes to deal with the hyphen in an argument name
attr_style(`background-color` = scale_col(c(NA, -1, 0, 0.5, 1)))

tag_attr(class = c(1, 2),
         style = attr_style(`background-color` = scale_col(c(-1,1))))

tokenbrowser documentation built on Oct. 23, 2020, 6:54 p.m.