Learn R Programming

mosaic (version 0.1-34)

aggregating: Aggregating summary statistics

Description

These drop-in replacements and new summary statistics functions are formula-aware. When given formulas, they call aggregate using the formula.

Usage

mean(x, ...)
## S3 method for class 'formula':
mean(x, data, na.rm=TRUE, ...)
## S3 method for class 'default':
mean(x, na.rm=TRUE, ...)

median(x, ...) ## S3 method for class 'formula': median(x, data, na.rm=TRUE, ...) ## S3 method for class 'default': median(x, na.rm=TRUE, ...)

sd(x, ...) ## S3 method for class 'formula': sd(x, data, na.rm=TRUE, ...) ## S3 method for class 'default': sd(x, na.rm=TRUE, ...)

var(x, ...) ## S3 method for class 'formula': var(x, data, na.rm=TRUE, ...) ## S3 method for class 'default': var(x, na.rm=TRUE, ...)

prop(x,...) ## S3 method for class 'logical': prop(x, level=TRUE, na.rm=TRUE, ...) ## S3 method for class 'factor': prop(x, level=levels(x)[1], na.rm=TRUE, ...) ## S3 method for class 'formula': prop(x, data, na.rm=TRUE, ...) ## S3 method for class 'default': prop(x, na.rm=TRUE, ...)

count(x,...) ## S3 method for class 'logical': count(x, level=TRUE, na.rm=TRUE, ...) ## S3 method for class 'factor': count(x, level=levels(x)[1], na.rm=TRUE, ...) ## S3 method for class 'formula': count(x, data, na.rm=TRUE, ...) ## S3 method for class 'default': count(x, na.rm=TRUE, ...)

Arguments

x
an R object, possibly a formula
data
a data frame for the formula methods
na.rm
a logical indicating whether missing data should be removed before calculation.
level
a level of a factor
...
additional arguments

Details

The default value for na.rm is reversed from the functions in stats.

See Also

link{aggregate}

Examples

Run this code
mean(age ~ sex, data=HELP)

Run the code above in your browser using DataLab