home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / factor < prev    next >
Encoding:
Text File  |  1997-04-23  |  1.7 KB  |  50 lines

  1.     
  2.     _F_a_c_t_o_r _V_a_r_i_a_b_l_e_s
  3.     
  4.          factor(x, levels=sort(unique(x)), labels,
  5.                  ordered=FALSE, exclude=NA)
  6.          ordered(x, levels=sort(unique(x)), labels, exclude=NA)
  7.     
  8.          is.factor(x)
  9.          is.ordered(x)
  10.          is.unordered(x)
  11.     
  12.          as.factor(x, ordered=FALSE)
  13.     
  14.     _V_a_l_u_e:
  15.     
  16.          The function factor is used to encode a vector as a
  17.          factor (the names category and enumerated type are also
  18.          used for factors).  If ordered is TRUE, the factor lev-
  19.          els are assumed ordered.  By default the levels are
  20.          unordered.  For compatibility purposes, there is also a
  21.          function called ordered which provides an alternative
  22.          way of creating ordered factors.
  23.     
  24.          The encoding of the vector happens as follows: if
  25.          x[i]==levels[j] then the i-th element of the result is
  26.          j.  If no match is found for x[i] in levels, then the
  27.          i-th element of the result is set to NA.  Any values
  28.          listed in exclude result in NAs appearinging in the
  29.          returned factor.  If exclude is set to a zero length
  30.          vector, then any NA values in x are used for form a new
  31.          level for the factor.  This means that there will be no
  32.          NA values in the result.
  33.     
  34.          labels is a vector of character strings used to label
  35.          the levels of the factor.  The default is to use the
  36.          encoded factor levels.
  37.     
  38.          is.factor returns TRUE or FALSE depending on whether
  39.          its argument is of type factor or not.  Correspond-
  40.          ingly, is.ordered (is.unordered) returns TRUE when its
  41.          argument is ordered (unordered) and FALSE otherwise.
  42.     
  43.          as.factor coerces its argument to a factor.  It is an
  44.          abbreviated form of factor.
  45.     
  46.     _S_e_e _A_l_s_o:
  47.     
  48.          gl, levels, nlevels.
  49.     
  50.