as.color | R Documentation |
Convenience function to convert a vector of values into a color specification.
as.color(x, opacity = 1)
is.color(x)
x |
vector of numeric, character or factor values to be transformed |
opacity |
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. Behavior of
The optional The These functions are used for the color parameters of
|
For as.color
, a vector integer values (corresponding to color
palette values) or character color name. For is.color
, a logical
vector indicating if each element of x appears to be a color
as.color()
returns TRUE if x is a character in a known color format.
as.color(1:3)
as.color(c('a','b','c'))
# add some transparency
as.color(c('red','green','blue'),0.5) # gives "#FF000080", "#00FF0080", "#0000FF80"
is.color(c('red',1,'foo',NA,'#FFFFFF55'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.