makeColorMatrix {leafgl} | R Documentation |
makeColorMatrix
Description
Transform object to rgb color matrix
Usage
makeColorMatrix(x, data, palette, ...)
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 |
... |
Passed to |
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
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)))
}
[Package leafgl version 0.1.1 Index]