gapply                 package: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 factor if necessary, and the unique
          levels are used to define the groups.  Defaults to
          'formula(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 function '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 Jose.Pinheiro@pharma.novartis.com and Douglas Bates
     bates@stat.wisc.edu

_S_e_e _A_l_s_o:

     'gsummary'

_E_x_a_m_p_l_e_s:

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

