dColorVector {DepecheR} | R Documentation

## Create a vector of colors of the same length as the data

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

    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

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

[Package DepecheR version 1.0.3 Index]