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 / Extract < prev    next >
Encoding:
Text File  |  1997-04-23  |  1.3 KB  |  40 lines

  1.     
  2.     _E_x_t_r_a_c_t _o_r _R_e_p_l_a_c_e _p_a_r_t_s _o_f _a_n _O_b_j_e_c_t
  3.     
  4.          x[i]
  5.          x[i,j, ...]
  6.          x[i,j, ..., drop=T]
  7.          x[[i]]
  8.          x[[i,j, ...]]
  9.          x$name
  10.     
  11.     _D_e_s_c_r_i_p_t_i_o_n:
  12.     
  13.          These operators act on vectors, matrices, dataframes
  14.          and lists.  If one of these expressions is on the left
  15.          hand side of an assignment then that part of x is set
  16.          to the value of the right hand side of the assignment.
  17.     
  18.          These operators are generic. You can write methods to
  19.          handle subsetting of specific classes of data.
  20.     
  21.          The [[ operator requires all relavent subscripts be
  22.          supplied.  With  the [ operator a comma separated blank
  23.          indicates that all entries in that dimension are
  24.          selected.
  25.     
  26.          When operating on a list the  [[ operator gives the
  27.          specified element of the list while the [ operator
  28.          returns a list with the specified element(s) in it.
  29.     
  30.     _E_x_a_m_p_l_e_s:
  31.     
  32.          x <- 1:12; m <- matrix(1:6,nr=2); li <- list(pi=pi, e = exp(1))
  33.          x[10]   # the tenth element of x
  34.          m[1,]   # the first row of m (which must be a matrix)
  35.          li[[1]] # the first element of list li
  36.          y<-list(1,2,a=4,5)
  37.          y[c(3,4)] # a list containing the third and fourth elements of y
  38.          y$a      #the element of y named a
  39.     
  40.