dColorVector: Create a vector of colors of the same length as the data

Description Usage Arguments Value See Also Examples

View source: R/dColorVector.R

Description

This function takes a vector x and a shorter ordering vector with all the unique values of the x vector in the specific order that the colors should be in and returns a vector of RGB colors the same length as the initial x vector.

Usage

1
dColorVector(x, colorOrder = unique(x), colorScale = "viridis")

Arguments

x

Any vector.

colorOrder

The order that the colors should be in in the output vector. Defaults to the order that the unique values in x occurs.

colorScale

The color scale. Inherited from the viridis, gplots and grDevices packages (and the package-specific 'dark_rainbow'). Seven possible scales are pre-made: inferno, magma, plasma, viridis, rich_colors, rainbow and dark_rainbow. User specified vectors of colors (e.g. c('#FF0033', '#03AF49')) are also accepted.

Value

A vector, the same length as x with each unique value substitutet with a color.

See Also

dDensityPlot, dColorPlot, dViolins

Examples

1
2
3
4
5
6
7
8
# Load some data
data(testData)

testColor <- dColorVector(testData$ids, colorScale = "plasma")

# In this case, each of the 97 individual donors in the dataset has gotten
# their own color code:
table(testColor)

DepecheR documentation built on Nov. 8, 2020, 5:44 p.m.