## The Problem

The range is another measure of how spread out the data are. Because it only uses two values, the largest and the smallest, the range is easy to calculate. It is also very unstable as an estimator of the population range. To illustrate calculating the range, assume that you collected the following 8 data values:

23, 41, 92, 49, 87, 37, 66, 9

Calculate the range of this sample.

## Your Answer

You got the correct answer of **83**. Congratulations!

Unfortunately, your answer was not correct. Either try again or click on “Show Solution” below to see how to obtain the correct answer.

## Assistance

Hide Solution

The sample range is the difference between the largest and the smallest values. The largest values is also called the maximum; the smallest, the minimum.

How to calculate the range with the data given above.
Step 1: | Calculate the maximum: | 92 |

Step 2: | Calculate the minimum: | 9 |

Step 3: | Calculate their difference: | 92 − 9 = 83 |

Hide the R Code

Copy and paste the following code into your R script window, then run it from there.

sample = c(23, 41, 92, 49, 87, 37, 66, 9)

diff(range(sample))

In the R output, the sample range is the number output by the script. **Note** that the R function `range`

calculates the minimum and maximum values. The function `diff`

just takes their difference, which calculates the range as we have defined it.

Hide the Excel Code

Copy and paste the following code into your Excel spreadsheet window, making sure your cursor is in `A1`

when you paste.

sample

23

41

92

49

87

37

66

9

=MAX(A2:A9)-MIN(A2:A9)

Note that there is no `RANGE`

function in Excel. The only way to calculate the range is to calculate the maximum and minimum values of the sample and take their difference.