

   AAppppllyy aa FFuunnccttiioonn bbyy GGrroouuppss

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

   AArrgguummeennttss::

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

        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'.

   DDeessccrriippttiioonn::

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

   VVaalluuee::

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

   AAuutthhoorr((ss))::

        Jose Pinheiro and Douglas Bates

   SSeeee AAllssoo::

        `gsummary'

   EExxaammpplleess::

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

