開始使用免費開始

使用 IQR 找出離群值

四分位距(interquartile range,IQR)是另一種衡量分散程度的方法,較不受離群值影響。IQR 也常用來找出離群值:若某個數值小於 $\text{Q1} - 1.5 \times \text{IQR}\(,或大於 \)\text{Q3} + 1.5 \times \text{IQR}$,就視為離群值。事實上,ggplot2 的盒鬚圖就是用這種方式計算鬚端的長度。

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

在這個練習中,你將計算 IQR,並用它來找出一些離群值。dplyrggplot2 函式庫已載入,且 food_consumption 已可使用。

本練習屬於課程

R 統計學入門

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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

# Compute the IQR of co2_emission
iqr <- ___
iqr
編輯並執行程式碼