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 7 data values:
66, 15, 82, 86, 88, 69, 59
Calculate the range of this sample.
Your Answer
You got the correct answer of 73. 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: | 88 |
Step 2: | Calculate the minimum: | 15 |
Step 3: | Calculate their difference: | 88 − 15 = 73 |
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
sample = c(66, 15, 82, 86, 88, 69, 59)
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
66
15
82
86
88
69
59
=MAX(A2:A8)-MIN(A2:A8)
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.