自定义 gapminder 显示
让我们用按国家的预期寿命变化轨迹图来测试这些功能。请注意,我们仍然只使用大洋洲的两个国家。
本练习是课程的一部分
使用 R 中的 Trelliscope 可视化大数据
练习说明
- 添加一个
geom_smooth()图层,并使用"lm"方法拟合线性模型。 - 将坐标轴缩放设置为
"sliced"。 - 在图中加入线性模型图层后,指定为该显示计算自动认知统计,并探索该图层为显示新增了哪些认知统计。
交互式实操练习
通过完成这段示例代码来试试这个练习。
library(trelliscopejs)
library(ggplot2)
# Create the plot
ggplot(gapminder, aes(year, lifeExp)) +
geom_point() +
geom_smooth(method = ___, se = FALSE) +
facet_trelliscope(~ country + continent,
name = "lifeExp_by_country",
desc = "Life expectancy vs. year for 142 countries.",
nrow = 1, ncol = 2,
# Set the scales
scales = ___,
# Specify automatic cognistics
auto_cog = ___)