MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to Statistics in R

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Compute the 25th percentile and 75th percentile of co2_emission
q1 <- quantile(___$___, ___)
q3 <- ___

# Compute the IQR of co2_emission
iqr <- ___
iqr
Edit dan Jalankan Kode