# Variance in R (Example)

This article explains how to calculate the variance of numeric data with the var() function in the R programming language.

## Example Data

my_values <- c(4, 1, 8, 5, 4, 4, 5, 6, 8, 1) # Create example values |

my_values <- c(4, 1, 8, 5, 4, 4, 5, 6, 8, 1) # Create example values

## Computation of Sample Variance in R (var Function)

We can compute the variance of our example data with the var function:

var(my_values) # Compute sample variance # 5.642857 |

var(my_values) # Compute sample variance # 5.642857

Note that the var function is computing the sample variance and not the population variance.