makeColorMatrix | R Documentation |
Transform object to rgb color matrix
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 |
{
## 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
testdf <- data.frame(
texts = LETTERS[1:10],
vals = 1:10,
vals1 = 11:20
)
makeColorMatrix("red", testdf)
makeColorMatrix("val", testdf)
## For formulaes
makeColorMatrix(~vals, testdf)
makeColorMatrix(~vals1, testdf)
## 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.