Skip to contents

Convert R colour to hexadecimal representation.

Usage

Col2Hex(col, alpha = FALSE)

Arguments

col

vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by colors()), a hexadecimal string (see Details), or a positive integer i meaning palette()[i].

alpha

logical value indicating whether the alpha channel (opacity) values should be returned.

Examples

Col2Hex(1:3)
#> [1] "#000000" "#DF536B" "#61D04F"
Col2Hex(c("peachpuff", "blue"), TRUE)
#> [1] "#FFDAB9FF" "#0000FFFF"