I am struggling to find a way to randomly mix discrete colors for my leaflet map for a large number of observations. The problem is the following command put similar colors next to each other which makes it hard to distinguish on the map.
library(leaflet)
previewColors(colorFactor("RdYlBu", domain = NULL), LETTERS[1:26])
Is there any way to mix colors in a way it becomes A,Z,B,Y and so on ...
Maybe something like this:
library(leaflet)
set.seed(50)
previewColors(colorFactor(sample(colors(),26), domain = NULL), LETTERS[1:26])
Or you could do something like this: library(leaflet) set.seed(500) previewColors(colorFactor(sample(rainbow(26),26), domain = NULL), LETTERS[1:26])