mosaic (version 0.8-1)

mean: Aggregating functions

Description

The mosaic package makes several summary statistic functions (like mean and sd) formula aware.

Usage

mean(x, ..., data, ..fun.. = base::mean)

median(x, ..., data, ..fun.. = stats::median)

range(x, ..., data, ..fun.. = base::range)

sd(x, ..., data, ..fun.. = stats::sd)

max(x, ..., data, ..fun.. = base::max)

min(x, ..., data, ..fun.. = base::min)

sum(x, ..., data, ..fun.. = base::sum)

IQR(x, ..., data, ..fun.. = stats::IQR)

fivenum(x, ..., data, ..fun.. = stats::fivenum)

iqr(x, ..., data, ..fun.. = stats::IQR)

prod(x, ..., data, ..fun.. = base::prod)

sum(x, ..., data, ..fun.. = base::sum)

favstats(x, ..., data, ..fun.. = fav_stats)

var(x, ..., data, ..fun.. = stats::var)

cor(x, y = NULL, ..., data = parent.frame())

cov(x, y = NULL, ..., data = parent.frame())

Arguments

x
an object, often a formula
y
an object, often a numeric vector
..fun..
the underlyin function used in the computation
data
a data frame in which to evaluate formulas (or bare names)
...
additional arguments

Examples

mean( HELPrct$age )
mean( ~ age, data=HELPrct )
mean( age ~ sex + substance, data=HELPrct )
mean( ~ age | sex + substance, data=HELPrct )
mean( sqrt(age), data=HELPrct )
sum( ~ age, data=HELPrct )
sd( HELPrct$age )
sd( ~ age, data=HELPrct )
sd( age ~ sex + substance, data=HELPrct )
var( HELPrct$age )
var( ~ age, data=HELPrct )
var( age ~ sex + substance, data=HELPrct )
IQR( width ~ sex, data=KidsFeet )
iqr( width ~ sex, data=KidsFeet )
favstats( width ~ sex, data=KidsFeet )

cor( length ~ width, data=KidsFeet )
cov ( length ~ width, data=KidsFeet )