For example:
blue
converts to:
#0000FF
I wrote it as:
Color color = Color.FromName(\"blue\
You can use gplots package:
library(gplots)
col2hex("blue")
# [1] "#0000FF"
https://cran.r-project.org/web/packages/gplots/index.html
Inside gplots package the code for col2hex function is:
col2hex <- function(cname)
{
colMat <- col2rgb(cname)
rgb(
red=colMat[1,]/255,
green=colMat[2,]/255,
blue=colMat[3,]/255
)
}