choosePalette | R Documentation |
Given a character vector of features and optionally a vector of color codes, this function evaluate if the supplied color codes has sufficient number of colours. It returns a named vector of color codes based on the input features, with the same length as the unique features.
choosePalette(object, color = c30(), quiet = TRUE)
object |
A character vector containing the discrete or categorical features. |
color |
A character vector of color codes. Default is to use |
quiet |
Logical scalar indicating whether to disable messaging.
Default is |
By default, it uses the c30()
palette when no more than 30 colours are
required, then the c40()
palette, and lastly the rainbow()
colour palette
when requiring more than 40 colours.
A named character vector
I-Hsuan Lin
c30()
, c40()
, grDevices::rainbow()
# When input is a vector
feat <- LETTERS[1:5]
feat
choosePalette(feat) # use c30()
# When input is a factor of 3 levels
feat <- factor(rep(LETTERS[1:3], 5))
feat
choosePalette(feat, rainbow(10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.