为图形添加标题
您还可以用许多其他方式自定义 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()