開始使用免費開始

用箱型圖檢視離群值

除了呈現分佈的中心與散佈之外,箱型圖也能以視覺方式偵測離群值。你可以把這個方法用在 msrp 欄(製造商建議零售價),看看是否存在特別昂貴或特別便宜的車款。

本練習屬於課程

R 的探索式資料分析

檢視課程

練習說明

  • 繪製 msrp 的箱型圖。
  • 透過篩選資料列,僅保留價格低於 $100,000 的車款,以排除最大的 3–5 個離群值。將這個縮減後的資料集儲存為 cars_no_out
  • 使用這個縮減後的資料集,再繪製一張相同設定的 msrp 箱型圖。比較兩張圖。

動手互動練習

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

# Construct box plot of msrp
cars %>%
  ggplot(aes(x = 1, y = ___)) +
  geom_boxplot()

# Exclude outliers from data
cars_no_out <- cars %>%
  filter(___)

# Construct box plot of msrp using the reduced dataset
cars_no_out %>%
  ___ +
  ___
編輯並執行程式碼