Learn R Programming

ggtern (version 3.5.0)

rgb2hex: Convert RGB to HEX Color

Description

Function to convert rgb color to hex color

Usage

rgb2hex(r = 0, g = 0, b = 0)

Arguments

r, g, b

colors, numeric scalar between 0 and 255

Author

Nicholas Hamilton

Examples

Run this code
#Black
rgb2hex(0,0,0)

#White
rgb2hex(255,255,255)

#Red
rgb2hex(255,0,0)

#Green
rgb2hex(0,255,0) 

#Blue
rgb2hex(0,0,255)

#Vectorised sequence of blue
rgb2hex(0,0,seq(0,255,by=5))

Run the code above in your browser using DataLab