Learn R Programming

mosaic (version 0.4-1)

maggregate: Aggregate for mosaic

Description

Compute function on subsets of a variable in a data frame.

Usage

maggregate(formula, data = parent.frame(), FUN, subset,
    overall = mosaic.par.get("aggregate.overall"),
    format = c("default"), drop = FALSE, multiple = FALSE,
    ...)

Arguments

formula
a formula. Left side provides variable to be summarized. Right side and condition describe subsets. If the left side is empty, right side and condition are shifted over as a convenience.
data
a data frame
FUN
a function to apply to each subset
subset
a logical indicating a subset of data to be processed.
drop
a logical indicating whether unused levels should be dropped.
format,overall
currently unused
multiple
logical indicating whether FUN returns multiple values
...
additional arguments passed to FUN

Value

  • a vector

Examples

Run this code
maggregate( cesd ~ sex, HELPrct, FUN=mean )
maggregate( cesd ~ sex & homeless, HELPrct, FUN=mean )
maggregate( cesd ~ sex | homeless, HELPrct, FUN=sd )

Run the code above in your browser using DataLab