Skip to content
Prev 360161 / 398503 Next

Mean of hexadecimal numbers

Since these are color strings, you can use functions in the grDevices
package (other others) to manipulate them.  E.g., you can convert them
to various color spaces and perhaps use the mean in one of those
spaces as your 'average color'.

  > myColors <- c(One="#FF7C00",Two="#00BF40",Three="#FFFF00")
  > col2rgb(myColors)
        One Two Three
  red   255   0   255
  green 124 191   255
  blue    0  64     0
  > rgb2hsv(col2rgb(myColors))
           One       Two     Three
  h 0.08104575 0.3891798 0.1666667
  s 1.00000000 1.0000000 1.0000000
  v 1.00000000 0.7490196 1.0000000



Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Apr 16, 2016 at 8:27 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: