Transform object to rgb color matrix
Arguments
- 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
colourvalues
is installed, it is passed tocolour_values_rgb
. To see all available palettes, please usecolour_palettes
. Ifcolourvalues
is not installed, the palette is passed tocolorNumeric
.- ...
Passed to
colour_palettes
orcolorNumeric
.
Examples
{
## 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)))
}
#> [,1] [,2] [,3]
#> [1,] 0.2666667 0.003921569 0.3294118
#> [2,] 0.9921569 0.905882353 0.1450980