Re: [R] hex format

From: Thomas Lumley <>
Date: Fri 08 Apr 2005 - 03:40:36 EST

On Thu, 7 Apr 2005, Earl F. Glynn wrote:
> 1) While generally I'd agree with your statement, manipulating colors is one
> place the ability to convert to/from hex would be quite nice.
>> rgb(1,0,0.5)
> [1] "#FF0080"
> rgb returns a hex string and then R makes manipulating this string somewhat
> difficult. One might want to use such color values to convert to a
> different color space, perform some sort of manipulation in that other color
> space, and then convert back to rgb.

The convertColor function in R 2.1.0 provides colorspace conversion, including "hex".

> 5) Does R have a hex consistency problem? The color values start with a "#"
> for hex, but the as.numeric("#FF0080") isn't allowed?

#ff0080 isn't a number, it's a colour (or perhaps a color). If it were converted to numeric form it would be a vector of three numbers, and which three numbers would depend on the coordinate system used for colour space. For example, R already provides both hsv() and rgb() to create colours from vectors of three numbers, but the correspondence is different in each case.

         -thomas mailing list PLEASE do read the posting guide! Received on Fri Apr 08 03:47:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:04 EST