avg | R Documentation |
Calculate the mean, median, or mode of a vector.
avg(x, center = mean)
x |
A vector to summarize. |
center |
A function to use to calculate the central tendency for numeric vectors. Defaults to |
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.
A single value summarizing x
.
Kylie A. Bemis
mean
,
median
set.seed(1)
x <- sample(LETTERS, 50, replace=TRUE)
y <- runif(50)
avg(x)
avg(y)
avg(y, median)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.