avg: Central Tendency

View source: R/utils.R

avgR Documentation

Central Tendency

Description

Calculate the mean, median, or mode of a vector.

Usage

avg(x, center = mean)

Arguments

x

A vector to summarize.

center

A function to use to calculate the central tendency for numeric vectors. Defaults to mean.

Details

Missing values are always removed before calculating the central tendency. The center funtion will be used to calculate the central tendency for any x for which either is.numeric or is.complex is TRUE. Otherwise, the mode is calculated.

Value

A single value summarizing x.

Author(s)

Kylie A. Bemis

See Also

mean, median

Examples

set.seed(1)
x <- sample(LETTERS, 50, replace=TRUE)
y <- runif(50)

avg(x)
avg(y)
avg(y, median)

kuwisdelu/matter documentation built on Sept. 18, 2024, 6:31 p.m.