This function creates marking of points by color or symbol for use in graphs.
markby(z, use="color", values=NULL, color.fn=rainbox, na.action="na.use")
z |
a variable with a few distict values that will define the groups for marking. |
use |
if equal to "color" , will returna list of colors. If
anything else, it will return a list of symbols for marking. |
values |
a list with as many values as unique values of z that determine the colors or symbols. If this is not set, then the function rainbow is used for colors and 1:length(unique(z)) is used for symbols. |
color.fn |
|
na.action |
By default, missing values (NAs) are treated as another category in the color marking. Setting this argument to anything else will return NA for the missing category names. This will cause an error in R graphics routines, but see below for usage of this options. |
Returns length(z) values that specify the color or symbol for each point.
Sanford Weisberg, <sandy@stat.umn.edu>
This function is to help users familiar with Arc, as discussed in R. D. Cook and S. Weisberg (1999). Applied Regression Including Computing and Graphics, New York: Wiley.
x <- rnorm(100) y <- rnorm(100) z <- cut(rnorm(100),3) # Scatterplot, mark using color with groups determined by Status plot(x,y,col=markby(z)) # Scatterplot, mark using symbols with groups determined by Status plot(x,y,pch=markby(z,use="symbols")) # handing of missing values: z[1:10] <- NA # set to missing marks <- markby(z,na.action="omit") sel <- !is.na(marks) plot(x[sel],y[sel],col=marks[sel])