Convenience function to convert a vector of values into a color specification.
vector of numeric, character or factor values to be transformed
optional numeric value in the range 0.0 to 1.0 used to specify the opacity/transparency (alpha) of the colors to be returned. 0 means fully opaque, 1 means fully transparent.
as.color is as follows:
integer numeric values: unchanged, (assumed to corespond to values of R's active
integer real values: will be translated to into grayscale values ranging between the max and min
factor: integer values corresponding to factor levels will be used
character: if values are valid colors (as determined by
is.color) they will be returned as is. Otherwise converted to factor and numeric value of factor returned.
opacity parameter can be used to make colors partially transparent (as a shortcut for
adjustcolor. If used, colors will be returned as hex rgb color string (i.e.
is.color function checks if each character element of
x appears to be a color name by comparing it to
colors and checking if it is an HTML-style hex color code. Note that it will return FALSE for integer values.
These functions are used for the color parameters of
as.color, a vector integer values (corresponding to color palette values) or character color name.
is.color, a logical vector indicating if each element of x appears to be a color
1 2 3 4 5 6 7
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.