The variance is a numerical measure of how the data values is dispersed around themean. In particular, the sample variance is defined as:
![Variance | R Tutorial (1) Variance | R Tutorial (1)](https://i0.wp.com/www.r-tutor.com/www.r-tutor.com/sites/default/files/images/numerical-measures5x.png)
Similarly, the population variance is defined in terms of the population mean μand population size N:
![Variance | R Tutorial (2) Variance | R Tutorial (2)](https://i0.wp.com/www.r-tutor.com/www.r-tutor.com/sites/default/files/images/numerical-measures6x.png)
Problem
Find the sample variance of the eruption duration in the data set faithful.
Solution
We apply the var function to compute the sample variance of eruptions.
>duration=faithful$eruptions#theeruptiondurations
>var(duration)#applythevarfunction
[1]1.3027
Answer
The sample variance of the eruption duration is 1.3027.
Exercise
Find the sample variance of the eruption waiting periods in faithful.