

gapply(nlme)                                 R Documentation

_A_p_p_l_y _a _F_u_n_c_t_i_o_n _b_y _G_r_o_u_p_s

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

     Applies the function to the distinct sets of rows of
     the data frame defined by `groups'.

_U_s_a_g_e_:

     gapply(object, which, FUN, form, level, groups, ...)

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

  object: an object to which the function will be applied -
          usually a `groupedData' object or a `data.frame'.
          Must inherit from class `data.frame'.

   which: an optional character or positive integer vector
          specifying which columns of `object' should be
          used with `FUN'. Defaults to all columns in
          `object'.

     FUN: function to apply to the distinct sets of rows of
          the data frame `object' defined by the values of
          `groups'.

    form: an optional one-sided formula that defines the
          groups.  When this formula is given the right-hand
          side is evaluated in `object', converted to a fac-
          tor if necessary, and the unique levels are used
          to define the groups.  Defaults to `for-
          mula(object)'.

   level: an optional positive integer giving the level of
          grouping to be used in an object with multiple
          nested grouping levels.  Defaults to the highest
          or innermost level of grouping.

  groups: an optional factor that will be used to split the
          rows into groups.  Defaults to `getGroups(object,
          form, level)'.

     ...: optional additional arguments to the summary func-
          tion `FUN'.  Often it is helpful to specify `na.rm
          = TRUE'.

_V_a_l_u_e_:

     Returns a data frame with as many rows as there are
     levels in the `groups' argument.

_A_u_t_h_o_r_(_s_)_:

     Jose Pinheiro and Douglas Bates

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

     `gsummary'

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

     library( nlme )
     data( Quinidine )
     ## Find number of non-missing "conc" observations for each Subject
     gapply( Quinidine, FUN = function(x) sum(!is.na(x$conc)) )

