scope                 package:scope                 R Documentation

_S_p_e_c_i_f_y _A_r_b_i_t_r_a_r_y _R_o_w _N_a_m_e _S_u_b_s_e_t_s

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

     Create or refine a list of vectors of row names.  Each vector
     corresponds to  a row in a data frame, and its elements identify
     rows relevant to that row. Relevance is determined by the passed
     arguments.  Refinement consists of  passing the output back to the
     function with further criteria, effectively  nesting serial
     restrictions (scope can shrink but not grow).

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

     scope(x, this, FUN = "==", that = x[[this]], scope = NULL)

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

       x: A data frame.

    this: A column name in 'x', representing the first argument to
          'FUN'.

     FUN: A function taking two arguments, typically a comparison
          operator.

    that: A column name in 'x', representing the second argument to
          'FUN'; or a vector of same length as columns in 'x'; or an
          atomic value to be recycled.

   scope: A scope object, e.g. created by previous use of 'scope'.
          Specifically, a list (same length as columns in 'x') of
          vectors of row  names in 'x'.

_D_e_t_a_i_l_s:

     A data frame and one of its column names must be specified ('x',
     'this').  Defaults  are chosen so that if nothing else is
     specified, per-row scope will be all  rows with the same value of
     'this' as the row in question.  'FUN' will operate on 'this' and
     'that', within 'scope', which is all rows, by default.  _All_
     values  of 'this' within 'scope' will be compared to _each_ value
     of 'that'. If comparison  evaluates to 'TRUE', the corresponding
     row name is retained in 'scope'.

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

     A list of vectors, one per row in 'x', of relevant row names in
     'x'.

_S_e_e _A_l_s_o:

     'score', 'skim', 'scoop', 'probe'

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

     data(Theoph)
     #For each row, consider only those rows with the same Subject
     S <- scope(x=Theoph, this='Subject', FUN='==', that='Subject')
     #Same effect as...
     S <- scope(Theoph,'Subject')
     #For each row within Subject, consider only those rows having non-zero times.
     S2 <- scope(Theoph,'Time','>',0,scope=S)

