開始使用免費開始

繪製你的第一張圖

為了先熟悉 ggplot2,來試著執行一些基本的 ggplot2 指令吧。mtcars 資料集來自 1973 年 Motor Trend 雜誌,包含 32 款汽車的資訊。這個資料集小巧、直觀,且同時包含多種連續與類別變數。

本練習屬於課程

ggplot2 資料視覺化入門

檢視課程

練習說明

  • 使用 library() 載入 ggplot2 套件。
  • str() 探索 mtcars 資料集的結構。
  • 送出程式碼。這會執行範例程式碼。看看你是否能理解 ggplot 如何處理這些資料。

動手互動練習

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

# Load the ggplot2 package
___

# Explore the mtcars data frame with str()
___

# Execute the following command
ggplot(mtcars, aes(cyl, mpg)) +
  geom_point()
編輯並執行程式碼