string.to.colors: Convert between strings to colors

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/string.to.color.R

Description

Automatically convert a vector of strings into a color for easy plotting

Usage

1
string.to.colors(string, colors = NULL, alpha = 1)

Arguments

string

a vector of strings representing groups.

colors

a vector of colors, one for each unique element in string.

alpha

a transparency value to apply to all colors (or a vector of transparency values)

Value

a vector of colors, one for each element in string

Note

This function can also be used to specify pch values, cex values, or any other plotting values the user may wish to differ across groups. See examples.

Author(s)

Dustin Fife

See Also

number.to.colorsalpha

Examples

1
2
3
4
groups = sample(LETTERS[1:5], size=100, replace=TRUE)
plot(rnorm(100), rnorm(100), col=string.to.colors(groups))
plot(rnorm(100), rnorm(100), col=string.to.colors(groups), 
   pch=as.numeric(string.to.colors(groups, colors=c(16:20))))

dustinfife/fifer documentation built on Oct. 31, 2020, 3:36 p.m.