Using Colors in R

The statistical programming language R allows you to specify colors for your output in multiple ways, all of which follow the “col” command, which is short for “color” or “colour.” For example, all five of these methods refer to the same shade of red:

  • Color name: col = "red3"
  • Hex code: col = "#CD0000"
  • RGB (0-255): col = rgb(205, 0, 0, max = 255)
  • RGB (0.00-1.00): col = rgb(.80, .00, .00)
  • Index number: col = colors() [555]

You can browse the color data in the embedded Google Sheet, open the Google Sheet in a new window, download a Microsoft Excel version of the file, or download a PDF version.

With the exception of white, which is at the top of the list, the 657 colors are listed in alphabetical order, which corresponds to their index numbers. The grays are listed twice to accommodate differences in spelling (“gray” for the US and “grey” for the UK, for example) but have their own index numbers.

You can freely use, share, and adapt this data – even commercially – as long as you properly attribute it to Barton Poulson and datalab.cc, thanks to a Creative Commons Attribution 4.0 International License (CC-BY 4.0).