開始使用免費開始

不合邏輯的重量

把殼高為 0 mm 的鮑魚移除只是開始。在本練習中,你也會檢查鮑魚各部位的重量。wholeWeight 是鮑魚的總重量(單位:公克),包含鮑魚肉與殼的重量。因此,wholeWeight 應該要大於 shuckedWeightvisceraWeightshellWeight

如同你在前面練習看到的,有些 pctShucked 大於 100%,代表 shuckedWeight 大於 wholeWeight 的情況。在本練習中,你會檢視並視覺化這些案例,然後把它們從資料集 abaloneKeep 中移除。abaloneKeep 已從上一個練習載入,dplyrggplot2 套件也已載入。

本練習屬於課程

給 SAS 使用者的 R

檢視課程

練習說明

  • pctShuckedabaloneKeep 進行排序,擷取 abaloneKeeppctShucked 並查看最後 6 列。
  • 繪製散佈圖:x 軸為 wholeWeight,y 軸為 shuckedWeight,並加入 geom_abline(),截距為 0、斜率為 1。
  • 使用 dplyr 套件的 filter(),保留 shuckedWeight 小於 wholeWeight 的案例。

動手互動練習

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

# Sort abaloneKeep by pctShucked, view largest 6 pctShucked
abaloneKeep %>%
  ___ %>%
  ___ %>%
  ___

# Scatterplot of shuckedWeight by wholeWeight add y=x line
ggplot(___) +
  ___ +
  ___

# Keep cases where shuckedWeight is less than wholeWeight
abaloneKeep <- abaloneKeep %>%
  ___
編輯並執行程式碼