# Learn R: Quartiles, Quantiles, and Interquartile Range

In this course, you will learn how to calculate three important descriptive statistics that describe the spread of the data.

Start## Key Concepts

Review core concepts you need to learn to master this subject

Quantiles

Quartiles

Quantiles and Groups

Median in Quantiles

Interquartile Range Definition

Interquartile Range and Outliers

Quantiles

Quantiles

Quantiles are the set of values/points that divides the dataset into groups of equal size. For example, in the figure, there are nine values that splits the dataset. Those nine values are quantiles.

Quartiles

Quartiles

The three dividing points (or quantiles) that split data into four equally sized groups are called quartiles. For example, in the figure, the three dividing points Q1, Q2, Q3 are quartiles.

Quantiles and Groups

Quantiles and Groups

If the number of quantiles is n, then the number of equally sized groups in a dataset is n+1.

Median in Quantiles

Median in Quantiles

The median is the divider between the upper and lower halves of a dataset. It is the 50%, 0.5 quantile, also known as the 2-quantile.

Interquartile Range Definition

Interquartile Range Definition

The interquartile range is the difference between the first(Q1) and third quartiles(Q3). It can be mathematically represented as `IQR = Q3 - Q1`

.

Interquartile Range and Outliers

Interquartile Range and Outliers

The interquartile range is considered to be a robust statistic because it is not distorted by outliers like the average (or mean).

- 1A common way to communicate a high-level overview of a dataset is to find the values that split the data into four groups of equal size. By doing this, we can then say whether a new datapoint fall…
- 2We’ll come back to the music dataset in a bit, but let’s first practice on a small dataset. Let’s begin by finding the second quartile (Q2). Q2 happens to be exactly the median . Half of the dat…
- 3Now that we’ve found Q2, we can use that value to help us find Q1 and Q3. Recall our demo dataset: c(-108, 4, 8, 15, 16, 23, 42) In this example, Q2 is 15. To find Q1, we take all of the data poi…
- 4You just learned a commonly used method to calculate the quartiles of a dataset. However, there is another method that is equally accepted that results in different values! Note that there is no …
- 5We were able to find quartiles manually by looking at the dataset and finding the correct division points. But that gets much harder when the dataset starts to get bigger. Luckily, there is a funct…
- 6Great work! You now know how to calculate the quartiles of any dataset by hand and with R. Quartiles are some of the most commonly used descriptive statistics. For example, You might see schools …

- 1Quantiles are points that split a dataset into groups of equal size. For example, let’s say you just took a test and wanted to know whether you’re in the top 10% of the class. One way to determine …
- 2Base R has a function named quantile() that will quickly calculate the quantiles of a dataset for you. quantile() takes two parameters. The first is the dataset that you are using. The second para…
- 3In the last exercise, we found a single “quantile” — we split the first 23% of the data away from the remaining 77%. However, quantiles are usually a set of values that split the data into g…
- 4One of the most common quantiles is the 2-quantile. This value splits the data into two groups of equal size. Half the data will be above this value, and half the data will be below it. This is als…
- 5Nice work! Here are some of the major takeaways about quantiles:
*Quantiles are values that split a dataset into groups of equal size.*If you have n quantiles, the dataset will be split into n+…

- 1One of the most common statistics to describe a dataset is the
*range*. The range of a dataset is the difference between the maximum and minimum values. While this descriptive statistic is a good s… - 2The interquartile range is the difference between the third quartile (Q3) and the first quartile (Q1). If you need a refresher on quartiles, you can take a look at our lesson . For now, all you …
- 3In the last exercise, we calculated the IQR by finding the quartiles using R and finding the difference ourselves. The stats library has a function that can calculate the IQR all in one step. The …
- 4Nice work! You can now calculate the Interquartile Range of a dataset using R. The main takeaway of the IQR is that it is a statistic, like the range, that helps describe the spread of the center o…

## What you'll create

Portfolio projects that showcase your new skills

## How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory