Translates a factor into colors.
Arguments
- x
a numeric vector (for num2col) or a vector converted to a factor (for fac2col).
- col.pal
(default funky_color) a function generating colors according to a given palette.
- na.col
(default grey) the color to be used for missing values (NAs)
- seed
(default NULL) a seed for R's random number generated, used to fix the random permutation of colors in the palette used; if NULL, no randomization is used and the colors are taken from the palette according to the ordering of the levels
See also
The R package RColorBrewer, proposing a nice selection of color palettes. The viridis package, with many excellent palettes
Examples
fac2col(c("a", "b", "a", "c"))
#> [1] "#A6CEE3" "#F06C45" "#A6CEE3" "#B15928"