Builds a table with colors to merge with a dataframe for later use in ggplot. An initial check will be done on the name of the color vector. A data frame is built. It contains a column color which is a factor. The factor order match the order of the vector (not the alphabetical order of the colors).
colortable(
color = NULL,
vec,
palette = "Set2",
color_function = c("brewer.pal", "gray.colors", "random")
)
A dataframe with two columns, the vector (name) and the color (color) as a reordered factor
Either null (default) or a named vector of colors, the names should correspond to the values of vec
The vector to match the color with, if a named vector or color is supplied the names should match
the name of the RColorBrewer palette, defaults to "Set2", ignored for other color gradient functions and if a named vector of colors is provided
the name of the function used to brew the colors, one for "brewer.pal", "gray.colors", "random", default to "brewer.pal, this argument is ignored if a named vector of color is passed.
Cedric Briand cedric.briand@eptb-vilaine.fr