開始使用免費開始

盒狀圖與小提琴圖

這個練習會繼續讓你用 ggplot2 套件繪圖。此練習已經為你載入 ggplot2。你將把類別變數 sex 與連續變數 shuckedWeight(來自 abalone 資料集)一起放入圖中,使用 geom_boxplot() 繪製群聚盒狀圖,並使用 geom_violin() 繪製小提琴圖,這些圖形在呈現分佈時通常比單純盒狀圖更清楚。你也可以使用 ggplot2 的函式(例如 theme_bw())來加入主題,變更圖表風格(色彩、字型、格線等)。

abalone 資料集,以及 dplyrggplot2 套件都已為你載入。

本練習屬於課程

給 SAS 使用者的 R

檢視課程

動手互動練習

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

# Create graphical environment for sex and shuckedWeight
ggplot(data = ___, aes(___, ___))
編輯並執行程式碼