Convert RGB or RGBA values to HEX color codes. Accepts either a numeric
vector or a data.frame, symmetrically with hex2rgb().
Arguments
- rgb
A numeric vector of length 3 (
r,g,b) or 4 (r,g,b,alpha), or a data.frame withr,g,b, and optionalalphacolumns. Matrices and arrays are not accepted. Values must lie in[0, 255]and are rounded to the nearest integer, with exact halves rounded up. In a data.frame,alpha = NAemits 6-digit HEX; a finite alpha value emits 8-digit HEX. Data frames must contain at least one row; unrelated extra columns are ignored.
