Description Usage Arguments Examples
Transform object to rgb color matrix
1 | makeColorMatrix(x, data, palette, ...)
|
x |
Object representing the color. Can be of class integer, numeric, Date, POSIX*, character with color names or HEX codes, factor, matrix, data.frame, list, json or formula. |
data |
The dataset |
palette |
Name of a color palette. If |
... |
Passed to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | {
## For Integer/Numeric/Factor
makeColorMatrix(23L)
makeColorMatrix(23)
makeColorMatrix(as.factor(23))
## For POSIXt / Date
makeColorMatrix(as.POSIXlt(Sys.time(), "America/New_York"), NULL)
makeColorMatrix(Sys.time(), NULL)
makeColorMatrix(Sys.Date(), NULL)
## For matrix/data.frame
makeColorMatrix(cbind(130,1,1), NULL)
makeColorMatrix(matrix(1:99, ncol = 3, byrow = TRUE), data.frame(x=c(1:33)))
makeColorMatrix(data.frame(matrix(1:99, ncol = 3, byrow = TRUE)), data.frame(x=c(1:33)))
## For characters
library(leaflet)
makeColorMatrix("red", breweries91)
makeColorMatrix("blue", breweries91)
makeColorMatrix("#36ba01", breweries91)
makeColorMatrix("founded", data.frame(breweries91))
## For formulaes
makeColorMatrix(~founded, breweries91)
makeColorMatrix(~founded + zipcode, breweries91)
## For JSON
library(jsonify)
makeColorMatrix(jsonify::to_json(data.frame(r = 54, g = 186, b = 1)), NULL)
## For Lists
makeColorMatrix(list(1,2), data.frame(x=c(1,2)))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.