You can use the Polychrome package for this purpose. It just requires the number of colors and a few seedcolors
. For example:
# install.packages("Polychrome")
library(Polychrome)
# create your own color palette based on `seedcolors`
P36 = createPalette(36, c("#ff0000", "#00ff00", "#0000ff"))
swatch(P36)
You can learn more about this package at https://www.jstatsoft.org/article/view/v090c01.