開始使用免費開始

繪圖與布局

在你開始用 rlang 建立自訂函式之前,先用 ggplot2 以兩個變數製作散佈圖,並以另一個變數上色。提醒一下,題目常以「y 對 x」的方式提供變數,其中「y」對應到垂直軸、「x」對應到水平軸。

本課的練習已為你載入 dplyrggplot2 套件,以及 world_bank_2015 tibble。world_bank_2015 是從 world_bank_data tibble 中篩選 year 等於 2015 的列所組成。

本練習屬於課程

使用 dplyr 進行程式設計

檢視課程

動手互動練習

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

# Fertility vs. infant mortality rate, colors by continent
scatter <- ggplot(___, 
                  aes(x = infant_mortality_rate, 
                      y = ___)) +
             ___(aes(color = ___))
scatter
編輯並執行程式碼