比較人口與人均 GDP
在影片中你學到如何建立散佈圖,將人均 GDP 放在 x 軸、將預期壽命放在 y 軸(該圖的程式碼已提供在本練習中)。當你以視覺化方式探索資料時,通常需要嘗試不同的變數與美學對應組合。
本練習屬於課程
Tidyverse 入門
練習說明
- 將
gapminder_1952的散佈圖改成把人口數(pop)放在 x 軸,將人均 GDP(gdpPercap)放在 y 軸。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
library(gapminder)
library(dplyr)
library(ggplot2)
gapminder_1952 <- gapminder %>%
filter(year == 1952)
# Change to put pop on the x-axis and gdpPercap on the y-axis
ggplot(gapminder_1952, aes(x = gdpPercap, y = lifeExp)) +
geom_point()