Learn R Programming

prismatic (version 1.1.2)

clr_extract_red: Extract RGB components

Description

Extract the red, green, or blue color components from a vector of colors.

Usage

clr_extract_red(col)

clr_extract_green(col)

clr_extract_blue(col)

clr_extract_alpha(col)

Value

Numeric vector of values.

Arguments

col

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

Details

The values of the output will range between 0 and 255.

Use [clr_extract()] if you are planning to extraction multiple components.

See Also

Other Extraction: clr_extract(), clr_extract_chroma(), clr_extract_hue()

Examples

Run this code
clr_extract_red(rainbow(100))
clr_extract_green(rainbow(100))
clr_extract_blue(rainbow(100))
clr_extract_alpha(rainbow(100))

Run the code above in your browser using DataLab