為圖表加入標題
你還可以用許多其他方式自訂 ggplot2 圖表,這些內容可以在其他 DataCamp 課程學到。你也能從線上資源取得相關知識,而這是很重要的能力。
作為本課程的最後一個練習,你將練習查詢 ggplot2 的使用方法,完成一個我們尚未示範過的任務。
本練習屬於課程
Tidyverse 入門
練習說明
- 替圖表加上標題:Comparing GDP per capita across continents。請用 Google 或 Bing 等搜尋引擎查詢該如何完成。
- 完成這個練習後,你就快完成整門課了。若你喜歡這門課的內容,歡迎在 twitter 上向 Dave 表達感謝,他一定會很開心。 Tweet to Dave
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
library(gapminder)
library(dplyr)
library(ggplot2)
gapminder_1952 <- gapminder %>%
filter(year == 1952)
# Add a title to this graph: "Comparing GDP per capita across continents"
ggplot(gapminder_1952, aes(x = continent, y = gdpPercap)) +
geom_boxplot() +
scale_y_log10()