getColorScheme | R Documentation |
This function takes a data.frame
or tibble
object and given the defined value field split this field into
chunks based on defined breaks. Each chunk has assigned unique color on a gradient scale.
getColorScheme(data.table = NULL, value.field = NULL, breaks = NULL)
data.table |
A |
value.field |
Either a column index or a column name present in submitted 'data.table' |
breaks |
User defined breaks in defined 'value.field' in order to split these values into chunks (Default : '5' roughly equally sized chunks). |
A list
containing original 'data.table' with extra column adding 'col.levels' based on defined 'breaks'.
List also contains element 'color' with a gradient color assigned to each 'col.level'.
David Porubsky
## Define a data table with column containig 100 random values
data.t <- data.frame("Identity" = runif(100, min = 0, max = 1) * 100)
## By default value column is divided into 5 equally sized chunks
## Each chunk has assigned unique gradient color
colorScheme.l <- getColorScheme(data.table = data.t, value.field = "Identity")
## Function returns a list containing original data table with extra color levels column
colorScheme.l$data
## as well as corresponding color scheme
colorScheme.l$colors
## User can also define custom breaks used to divide value.field into chunks.
getColorScheme(data.table = data.t, value.field = "Identity", breaks = c(0.25, 0.5, 0.75))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.