string.to.colors | R Documentation |
Automatically convert a vector of strings into a color for easy plotting
string.to.colors(string, colors = NULL)
string |
a vector of strings representing groups. |
colors |
a vector of colors, one for each unique element in |
a vector of colors, one for each element in string
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.
Dustin Fife
number.to.colors
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))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.