markby                  package:dr                  R Documentation

_P_r_o_d_u_c_e _a _v_e_c_t_o_r _o_f _c_o_l_o_r_s/_s_y_m_b_o_l_s _t_o _m_a_r_k _p_o_i_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function creates marking of points by color or symbol for use
     in graphs.

_U_s_a_g_e:

     markby(z, use="color", values=NULL, color.fn=rainbox, na.action="na.use")

_A_r_g_u_m_e_n_t_s:

       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.

_V_a_l_u_e:

     Returns length(z) values that specify the color or symbol for each
     point.

_A_u_t_h_o_r(_s):

     Sanford Weisberg, <sandy@stat.umn.edu>

_R_e_f_e_r_e_n_c_e_s:

     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.

_E_x_a_m_p_l_e_s:

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

