powered by
Convert an RGB triplet (or a list of triplets) to HEX color codes.
rgb2hex(rgb)
A HEX color string if a single RGB vector is provided, or a character vector of HEX codes if a list is provided.
A numeric vector of length 3 (e.g., c(255, 128, 0)), or a list of such vectors (e.g., list(c(255,128,0), c(0,255,0))).
c(255, 128, 0)
list(c(255,128,0), c(0,255,0))
rgb2hex(c(255, 128, 0)) # "#FF8000" rgb2hex(list(c(255,128,0), c(0,255,0))) # c("#FF8000", "#00FF00")
Run the code above in your browser using DataLab