# 50 random RGB colors
rgb_random <- matrix(runif(150), nrow = 50, ncol = 3)
# default clustering (Lab space):
hclust_color(rgb_random, return_list = FALSE)
# clustering in RGB space (note change in Y-axis scale):
hclust_color(rgb_random, color_space = "sRGB", return_list = FALSE)
# clustering using only luminance:
hclust_color(rgb_random, channels = 1, return_list = FALSE)
# or only red-green ('a' channel):
hclust_color(rgb_random, channels = 2, return_list = FALSE)
# or only blue-yellow ('b' channel(:
hclust_color(rgb_random, channels = 3, return_list = FALSE)
# use a cutoff to get groups:
groups <- hclust_color(rgb_random, cutoff = 100)
print(groups)
Run the code above in your browser using DataLab