Learn R Programming

stacomiR (version 0.6.1)

colortable: 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).

Description

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).

Usage

colortable(
  color = NULL,
  vec,
  palette = "Set2",
  color_function = c("brewer.pal", "gray.colors", "random")
)

Value

A dataframe with two columns, the vector (name) and the color (color) as a reordered factor

Arguments

color

Either null (default) or a named vector of colors, the names should correspond to the values of vec

vec

The vector to match the color with, if a named vector or color is supplied the names should match

palette,

the name of the RColorBrewer palette, defaults to "Set2", ignored for other color gradient functions and if a named vector of colors is provided

color_function,

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.

Author

Cedric Briand cedric.briand@eptb-vilaine.fr