Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

labels2colors

Convert numerical labels to colors.


Description

Converts a vector or array of numerical labels into a corresponding vector or array of colors corresponding to the labels.

Usage

labels2colors(labels, zeroIsGrey = TRUE, colorSeq = NULL)

Arguments

labels

Vector of non-negative integer labels.

zeroIsGrey

If TRUE, labels 0 will be assigned color grey. Otherwise, labels below 1 will trigger an error.

colorSeq

Color sequence corresponding to labels. If not given, a standard sequence will be used.

Details

The standard sequence start with well-distinguishable colors, and after about 40 turns into a quasi-random sampling of all colors available in R with the exception of all shades of grey (and gray).

If the input labels have a dimension attribute, it is copied into the output, meaning the dimensions of the returned value are the same as those of the input labels.

Value

A vector or array of character strings of the same length or dimensions as labels.

Author(s)

Peter Langfelder, Peter.Langfelder@gmail.com

Examples

labels = c(0:20);
labels2colors(labels);

moduleColor

Basic Module Functions

v1.08-3
GPL (>= 2)
Authors
Peter Langfelder <Peter.Langfelder@gmail.com> and Steve Horvath <SHorvath@mednet.ucla.edu>
Initial release
2014-11-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.