nlme (version 3.1-86)

gapply: Apply a Function by Groups

Description

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

Usage

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

Arguments

Value

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

References

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. sec. 3.4.

See Also

gsummary

Examples

Run this code
## 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"]])) )

Run the code above in your browser using DataLab