Learn R Programming

mosaic (version 0.1-43)

aggregating: Aggregating summary statistics

Description

These drop-in replacements and new summary statistics functions are formula-aware and allow the use of simple names within data frames. When given formulas, they call aggregate using the formula.

Usage

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

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

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

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

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

prop(x, data=NULL, ...) ## 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, data=NULL, ...) ## 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
sd(age, data=HELP)
sd(~age, data=HELP)
sd(age ~ ., data=HELP)
sd(age ~ 1, data=HELP)
sd(age ~ NULL, data=HELP)
sd(HELP$age)
sd(age ~ sex, data=HELP)
sd( age ~ sex + treat, data=HELP)
sd(age ~ sex, data=HELP, overall=TRUE )
mosaic.par.set(aggregate.overall=TRUE)
sd(age ~ sex, data=HELP)

Run the code above in your browser using DataLab