Aan de slagGa gratis aan de slag

Comparing population and GDP per capita

In the video you learned to create a scatter plot with GDP per capita on the x-axis and life expectancy on the y-axis (the code for that graph has been provided in the exercise code). When you're exploring data visually, you'll often need to try different combinations of variables and aesthetics.

Deze oefening maakt deel uit van de cursus

Introduction to the Tidyverse

Cursus bekijken

Oefeninstructies

  • Change the scatter plot of gapminder_1952 so that (pop) is on the x-axis and GDP per capita (gdpPercap) is on the y-axis.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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()
Code bewerken en uitvoeren