Link Search Menu Expand Document

Table of contents

  1. Mean
    1. Definition
    2. Formula to calculate the mean
  2. Code example
    1. How to calculate the mean in R
  3. References

Mean

Definition

The mean, also known as the arithmetic mean or average, is the sum of all the numbers in a data set divided by the quantity of numbers in that set.

The mean is a measure of location.

Formula to calculate the mean

\begin{equation} \bar{x} = \frac{1}{n} \displaystyle\sum_{i=1}^{n}{x_i} = \frac{1}{n} (x_1 + x_2 + \ldots + x_n) \end{equation}

Code example

How to calculate the mean in R

# Create vector of numbers
x <- c(12, 7, 3, 4.2, 18, 2, 54, -21, 8, -5)

# Calculate and print mean
print(mean(x))

References