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 5 data values:
61, 48, 57, 44, 69
Calculate the range of this sample.
Your Answer
You got the correct answer of 25. 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: | 69 |
Step 2: | Calculate the minimum: | 44 |
Step 3: | Calculate their difference: | 69 − 44 = 25 |
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
sample = c(61, 48, 57, 44, 69)
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
61
48
57
44
69
=MAX(A2:A6)-MIN(A2:A6)
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.