probe                 package:scope                 R Documentation

_P_r_o_b_e _a _D_a_t_a _F_r_a_m_e _f_o_r _V_a_l_u_e_s _C_o_r_r_e_s_p_o_n_d_i_n_g _t_o _a _S_c_o_p_e_d _A_g_g_r_e_g_a_t_e

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

     For each row of a data frame, find the value in an arbitrary
     column and in the  row where some other column has the scoped
     aggregated value.

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

     probe(x, this, FUN = "max", that = this, scope = NULL, ...)
     select(x, from, among = NULL, where, is,  ...)

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

       x: A data frame (probe) or a column name (select)

    this: A column name in 'x', to which 'FUN' is applied, within
          scope.

     FUN: An aggregate function, preferably returning one of its
          arguments.

    that: The column from which to select return values, possibly the
          same as 'this'.

   scope: A scope object, identifying rows across which 'FUN' is
          applied, or  the name of an element in x of class scope.

     ...: Extra arguments to FUN.

    from: A data frame.

   among: A scope object, or name of one in x.

   where: A column in x.

      is: A function.

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

     'probe()' is a short-cut for a combination of 'skim()', 'scope()',
     and 'scoop()'.  That  is, given a data frame and a scope object,
     aggregate on one column and use  each aggregate value to find the
     row (if any) where the column value matches;  return the value in
     an arbitrary column for that row. NA is returned if there  is not
     exactly one match for the aggregate.

     'select()' is a SQL-like reargumentation of 'probe()'. See
     example.

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

     A vector of values of same length and mode as 'that'.

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

     'scope', 'score', 'skim', 'scoop'

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

     data(Theoph)
     #What is the time of the maximum concentration within subject (per row)?
     S <- scope(Theoph,'Subject')
     T <- probe(Theoph,'conc',that='Time',scope=S)
     U <- select('Time',from=Theoph,among=S,where='conc',is='max')
     # The T and U vectors above are not the same. You would need to switch 'conc' and 'Time' in
     # the select argument above to do the same thing. 

