Description Usage Arguments Value Implementation
Uses RColorBrewer palette names, default is OrRd with 9 colors Use more/less colors (n) for a bigger/smaller range, i.e. more/less extremes at each end. Colors are ordered according to the order of factor levels. If namesFrom given, add names to colors; otherwise, add names(x) or x.
1 | brewPalFac(x, n = 9, name = "OrRd", pull = NULL, namesFrom = NULL)
|
x |
Numeric vector/factor with optional names. |
n |
Number of colors for RColorBrewer (depends on the name). |
name |
Name of the RColorBrewer palette. |
pull |
Indices to pull colors from RColorBrewer::brewer.pal |
namesFrom |
Vector of names to be added to colors; default is names(x) or x. |
Named factor of colors of the same length as x where the order of colors corresponds to the order of x.
Levels of x are ordered as they apper in data; this is achieved by as.factor(x, levels=unique(x)) In the 2nd to the last line, we create a factor from colsn with levels ordered as they appear; In the last line, we reorder the levels of that factor according to the order of levels in x; xtfrm(unique(x)) reports indices of (unique) values in levels.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.