按大洲可视化人均 GDP 的中位数
条形图适合用来展示汇总统计量,例如各大洲的人均 GDP 中位数。
本练习是课程的一部分
Tidyverse 入门
练习说明
- 使用
group_by()和summarize()计算 1952 年各大洲内部的人均 GDP 中位数,将输出列命名为medianGdpPercap。使用赋值运算符<-将结果保存为名为by_continent的数据集。 - 使用
by_continent数据集创建条形图,显示各大洲的人均 GDP 中位数。
交互式实操练习
通过完成这段示例代码来试试这个练习。
library(gapminder)
library(dplyr)
library(ggplot2)
# Summarize the median gdpPercap by continent in 1952
# Create a bar plot showing medianGdp by continent