資料集內容
在這個練習中,你會學到如何查看 abalone 資料集的資訊與子集。你將使用 head() 與 tail() 檢視資料集的前 3 列與後 3 列。你也會依照殼紋圈數(rings)對鮑魚資料進行排序。
abalone 資料集與 dplyr 套件已為你載入。
本練習屬於課程
給 SAS 使用者的 R
練習說明
- 檢視 abalone 資料集的前 3 列與後 3 列。
- 使用
dplyr套件的arrange()函式,依殼紋圈數對鮑魚資料排序。 - 使用
dplyr的串接運算子%>%,改寫上方的 arrange 程式碼那一行。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# View top 3 rows of abalone dataset using head()
head(___, ___)
# View bottom 3 rows of abalone dataset using tail()
tail(___, ___)
# Run arrange function from dplyr to sort the data by rings
arrange(___, ___)
# Rewrite the line of code above using the %>% notation
___ %>%
___