Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 266
Definition: Arithmetic mean
Оглавление(for discrete distributions)
(for continuous distributions)
The unbiased estimator of the mean for K observations xk is:
mean
P()
probability
probability
f()
Not surprisingly, the arithmetic mean in R is calculated by the function mean()
.
probability density function
mean()
This is a dispatcher function1 and it will work in a meaningful way for a variety of objects, such as vectors, matrices, etc.
# The mean of a vector: x <- c(1,2,3,4,5,60) mean(x) ## [1] 12.5 # Missing values will block the override the result: x <- c(1,2,3,4,5,60,NA) mean(x) ## [1] NA # Missing values can be ignored with na.rm = TRUE: mean(x, na.rm = TRUE) ## [1] 12.5 # This works also for a matrix: M <- matrix(c(1,2,3,4,5,60), nrow=3) mean(M) ## [1] 12.5