| gapply {nlme} | R Documentation | 
Applies the function to the distinct sets of rows of the data frame
defined by groups.
gapply(object, which, FUN, form, level, groups, ...)
object | 
 an object to which the function will be applied - usually
a   | 
which | 
 an optional character or positive integer vector
specifying which columns of   | 
FUN | 
 function to apply to the distinct sets of rows
of the data frame   | 
form | 
 an optional one-sided formula that defines the groups.
When this formula is given the right-hand side is evaluated in
  | 
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   | 
... | 
 optional additional arguments to the summary function
  | 
Returns a data frame with as many rows as there are levels in the
groups argument.
Jose Pinheiro and Douglas Bates bates@stat.wisc.edu
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. sec. 3.4.
## Find number of non-missing "conc" observations for each Subject
gapply( Phenobarb, FUN = function(x) sum(!is.na(x$conc)) )
# Pinheiro and Bates, p. 127 
table( gapply(Quinidine, "conc", function(x) sum(!is.na(x))) )
changeRecords <- gapply( Quinidine, FUN = function(frm)
    any(is.na(frm[["conc"]]) & is.na(frm[["dose"]])) )