I want to use the R package SNA to do social network analysis. SNA colors elements only using R color names (text names).
I\'d like to find near matches from a ColorBrew
See if this is useful. (It's an LI distance on rgb space):
col.dist <- function(inp, comp) sum( abs(inp - col2rgb(comp) ) )
colors()[ apply(col2rgb(brew10), 2,
function(z) which.min( sapply(colors(),
function(x) col.dist(inp=z, comp=x) ) ) ) ]
#-----------
[1] "paleturquoise3" "moccasin" "lightsteelblue" "salmon"
[5] "lightskyblue3" "sandybrown" "darkolivegreen2" "thistle2"
[9] "gray85" "orchid3"
Looks like it might have succeeded looking at:
display.brewer.pal(10,"Set3")
(Although I have never see a thistle that color, and I would have thought number 7 to be more of a "lightolive" than a "darkolive".) You would proably get faster response, although this seemed acceptable, if you made the call to colors once and stored that matrix.