1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Introduction to Statistics in R

Connected

Bài tập

Finding outliers using IQR

Interquartile range, or IQR, is another way of measuring spread that's less influenced by outliers. IQR is also often used to find outliers. If a value is less than \(\text{Q1} - 1.5 \times \text{IQR}\) or greater than \(\text{Q3} + 1.5 \times \text{IQR}\), it's considered an outlier. In fact, this is how the lengths of the whiskers in a ggplot2 box plot are calculated.

Diagram of a box plot showing median, quartiles, and outliers

In this exercise, you'll calculate IQR and use it to find some outliers. Both dplyr and ggplot2 libraries are loaded and food_consumption is available.

Hướng dẫn 1/3

undefined XP
    1
    2
    3
  • Compute the first and third quartiles of co2_emission in food_consumption and store these as q1 and q3.
  • Calculate the interquartile range (IQR) of co2_emission and store it as iqr.