getColorScheme: Add color scheme based on certain values and defined breaks.

View source: R/helpers.R

getColorSchemeR Documentation

Add color scheme based on certain values and defined breaks.

Description

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.

Usage

getColorScheme(data.table = NULL, value.field = NULL, breaks = NULL)

Arguments

data.table

A data.frame or tibble object to be processed.

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).

Value

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'.

Author(s)

David Porubsky

Examples

## 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))


daewoooo/SVbyEye documentation built on March 31, 2024, 8:58 a.m.