看下面的例子:
> library(colorspace)
> # convert color with coordinates (0.2,0.3,0.4) in the RGB space into a character string:
> ( x <- hex(RGB(0.2,0.3,0.4)) )
[1] "#7C95AA"
> # reverse conversion:
> hex2RGB(x) ## not the original coordinates !
R G B
[1,] 0.4862745 0.5843137 0.6666667
> # now do the first conversion with the rgb() function from grDevices package:
> library(grDevices)
> ( y <- rgb(0.2,0.3,0.4) )
[1] "#334C66"
> # reverse conversion:
> hex2RGB(y) ## close to the original coordinates
R G B
[1,] 0.2 0.2980392 0.4
colorspace 包中的 hex() 函数似乎将 RGB 颜色空间中的三个坐标转换为字符串是错误的。这是一个错误,还是我错误地使用了这个包?