
R offers some awesome functions to deal with it. This post should guide you through
RColorBrewerRColorBrewer is the most famous package when it comes to build color palette with R. It provides quality continuous, sequential and categorical color palette. Examples below should get you started with this package, and give you an overview of all the available color palettes.
paletteerThe paletteer package gives access to all the existing color palettes in R.
library(paletteer) ; paletteer_c(package = "scico", palette = "berlin", n = 10)
Once you've found a color palette you like, you probably need to map it to a categorical or a numeric variable. This pretty easy to do with ggplot2, but much harder in base R. Basically, you have to transform the variable of interest in an integer that will be used to call the appropriate color.