不合邏輯的重量
把殼高為 0 mm 的鮑魚移除只是開始。在本練習中,你也會檢查鮑魚各部位的重量。wholeWeight 是鮑魚的總重量(單位:公克),包含鮑魚肉與殼的重量。因此,wholeWeight 應該要大於 shuckedWeight、visceraWeight 和 shellWeight。
如同你在前面練習看到的,有些 pctShucked 大於 100%,代表 shuckedWeight 大於 wholeWeight 的情況。在本練習中,你會檢視並視覺化這些案例,然後把它們從資料集 abaloneKeep 中移除。abaloneKeep 已從上一個練習載入,dplyr 與 ggplot2 套件也已載入。
本練習屬於課程
給 SAS 使用者的 R
練習說明
- 依
pctShucked對abaloneKeep進行排序,擷取abaloneKeep的pctShucked並查看最後 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 %>%
___